PS1() in Python like in Octave?
Question: I am taking an online machine learning course in Octave, and I am looking for
Python equivalents to Octave's commands. One such command is PS1(), which is a
function for changing the characters of the command prompt in Octave to a
passed string.

For example, the default prompt in my Octave command line interface is '> ',
but I could change it to '>> ' by entering the following command:

    
    
    PS1('>> ')
    

I've tried using the Google search engine, but I didn't find what I was
looking for.

Is there a Python equivalent for the PS1() function in Octave and, if so, what
is it?


Answer: Yes, it has them, just set
[`sys.ps1`](https://docs.python.org/2/library/sys.html#sys.ps1) and `sys.ps2`
variables:

    
    
    >>> import sys
    >>> sys.ps1 = '$$$ '
    $$$ sys.ps2 = '!!! '
    $$$ 
    $$$ while 0:
    !!!     True
    !!! 
    $$$ 
    

`sys.ps1` is a prompt for normal lines, while `sys.ps2` is a prompt for blocks
that should be indented (and thus, interpreter allow to pass multiple lines
before executing them), as you can see in `while` example.

BTW, `sys` module contain many helpful interpreter internal interfaces.

