Change Python interactive prompt ">>>"
It's great to set it to either:
- a color for better visual aspect
- a blank or space for easier copy/paste operations
Paste this into your Bash shell:
tee ~/.pyrc <<EOF
#!/usr/bin/env python3
import sys
# You also need \x01 and \x02 to separate escape sequence, due to:
# https://stackoverflow.com/a/9468954/1147688
sys.ps1='\x01\x1b[1;49;33m\x02>>>\x01\x1b[0m\x02 ' # bright yellow
sys.ps2='\x01\x1b[1;49;31m\x02...\x01\x1b[0m\x02 ' # bright red
EOF
Finally add this line to your ~/.bash_profile
:
export PYTHONSTARTUP=~/.pyrc
If you're on Windows, use one of these:
# Set it Temperarily (for this session)
$env:PYTHONSTARTUP="C:\Users\<USERNAME>\.pyrc"
# Set it Locally: HKEY_CURRENT_USER
[Environment]::SetEnvironmentVariable("PYTHONSTARTUP", 'C:\Users\<USERNAME>\.pyrc', 'User')
# Set it Globaly: HKEY_LOCAL_MACHINE
[Environment]::SetEnvironmentVariable("PYTHONSTARTUP", 'C:\Users\<USERNAME>\.pyrc', 'Machine')
# Set it Globaly: HKEY_LOCAL_MACHINE (also in CMD)
setx /m PYTHONSTARTUP "%HOME%\.pyrc"
Enjoy!
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>>>