Issue
I recall reading, in the Python 3.5 docs, how to change the >>>
on the Python interactive prompt, such as how calling help()
will change it to help>
.
But for some reason, when I've gone back to try and remember, I just can't find the instructions to it. Does anyone know if this is possible?
Solution
You remember correctly.
It's in the sys module (sys.ps1 & sys.ps2):
Strings specifying the primary and secondary prompt of the interpreter. These are only defined if the interpreter is in interactive mode. Their initial values in this case are '>>> ' and '... '. If a non-string object is assigned to either variable, its str() is re-evaluated each time the interpreter prepares to read a new interactive command; this can be used to implement a dynamic prompt.
For example:
>>> import sys >>> sys.ps1 = "3.5>>> " 3.5>>> sys.ps2 = "3.5... " 3.5>>>
Answered By - Gerrat
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.