[issue45892] Improve REPL with the underscore separators for int/float

2021-11-25 Thread Alex
Alex added the comment: Thanks a lot Eric for your answers, I did not know about sys.displayhook. Now I know I can easily implement this myself, but the larger question would be: "do we want to update the default displayhook for those simple use cases". -- ___

[issue45892] Improve REPL with the underscore separators for int/float

2021-11-24 Thread Eric V. Smith
Eric V. Smith added the comment: And you can probably use sitecustomize.py to import this. Since I don't see any action item here, I'm going to close this issue. -- resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tra

[issue45892] Improve REPL with the underscore separators for int/float

2021-11-24 Thread Eric V. Smith
Eric V. Smith added the comment: Oops, the float example should be: >>> 123123.9 123_123.9 -- ___ Python tracker ___ ___ Python-bu

[issue45892] Improve REPL with the underscore separators for int/float

2021-11-24 Thread Eric V. Smith
Eric V. Smith added the comment: We can't change the repr of int/float. However, you can use sys.displayhook to achieve what you want: import sys def displayhook(o): if o is None: return __builtins__._ = None if isinstance(o, (int, float)): print(format(o, '_'))

[issue45892] Improve REPL with the underscore separators for int/float

2021-11-24 Thread Alex
New submission from Alex : I often use to the Python REPL to perform some simple calculations (typically some combinatorial or probabilities computation). I believe it would be a nice improvement if the number displayed in the REPL would be formatted as if f"{result:_}" was given (with the und