Python interpreter prompt change

Good morning (all night): whale2: Since I started writing Python in a file, I'm touching an interpreter I've never used.

Start the interpreter


$ python
Python 3.5.1 |Anaconda 4.1.0 (x86_64)| (default, Jun 15 2016, 16:14:02)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

Super easy operation


>>> a = (
... 2,3,5,7
... )
>>> print(a)
(2, 3, 5, 7)
>>> exit()

The Python interpreter prompt string is obtained from the sys module.

Prompt string confirmation


>>> import sys
>>> sys.ps1
'>>> '
>>> sys.ps2
'... '
>>> exit()

It turns out that the interpreter's primary prompt (PS1) is " >>> " and the secondary prompt (PS2) is " ... ".

Try changing the prompt


>>> import sys
>>> sys.ps2 = '(๑•̀ㅂ•́)و '
>>> sys.ps1 = '(๑˃̵ᴗ˂̵)و '
(๑˃̵ᴗ˂̵)و '''
(๑•̀ㅂ•́)و interpreter
(๑•̀ㅂ•́)و Women's power
(๑•̀ㅂ•́)و Got up!
(๑•̀ㅂ•́)و '''
'\n Interpreter\n Women's power\n went up!\n'
(๑˃̵ᴗ˂̵)و exit()

The end

(๑˃̵ᴗ˂̵)و

References and annotations

Recommended Posts

Python interpreter prompt change
Change Maya Python Timeline
Website change monitoring using python
[Python] Change dtype with pandas
Change python version using pyenv
Debug with PEPPER python interpreter
How to change Python version
Python
[Python] Variable (definition, output, value change)
Change python default encoding to utf-8
Change the Python version of Homebrew
[Python] Change the alphabet to numbers
Did not change from Python 2 to 3
Change Python 64bit environment to 32bit environment with Anaconda
Change the length of Python csv strings
How to read pydoc on python interpreter
Run the Python interpreter in a script
Setting to change IPython prompt to'>>>' at startup
Launch the Python interpreter from Git bash
Python interpreter in Maya, Houdini, blender, Nuke
Connect to pepper with PEPPER Mac's python interpreter