What do the three arrow (">>>") signs mean?

PythonSyntaxCommand PromptCode Documentation

Python Problem Overview


I haven't been able to figure out what the >>> does, even though I often see it often in source code.

Python Solutions


Solution 1 - Python

You won't see it in source code, it's probably documentation. It indicates an interactive session, and things typed into the 'interpreter' are marked with this. Output is shown without the arrows.

In fact, the python documentation often has a button >>>at the top right of example code to be able to hide the arrows (and output) so that you can copy and paste the code.

Shown:
shown
Hidden:
hidden

Solution 2 - Python

'>>>' is the prompt of the interactive Python interpreter, meaning that the interpreter is ready to get Python statements typed in. It's occuring quite often in examples within the documentation of a Python program, in order to show which commands can be used and what will be the result of giving these commands to the interactive interpreter. For example, in a documentation of the print statement, one could give this example:

>>> print "Hello world."
Hello world.

This would be an actual snippet of a session with the interactive Python interpreter.

An interesting feature in IPython is that it ignores leading >>>, meaning that you can copy and paste code from such documentation without needing to remove the leading >>>:

In [1]: >>> print "Hello world."
Hello world.

(The prompt in IPython is In [n]:, where n is counting the interactive commands issued.)

Solution 3 - Python

Here are some of my findings on >>> and consequently ... complementing the previous answers.

You only see >>> when you are running Python in interactive mode prompting/asking the user for the "next command". Technical details here.


>>> and ... are not written in stone. These are stored in sys.ps1 and sys.ps2, and therefore can be changed. Further elaborated here.

>>> import sys
>>> sys.ps1 = "$ "
$

Every standard Python has this prompt unless you compile your own Python after changing >>> and ... to what you (sanely) wish to. Apart from that there seems to be a way to change it for all future interactive sessions by changing /usr/lib/python2.7/code.py but I couldn't find any success with it.

Solution 4 - Python

The >>> prompt is the Python interpreter’s way of asking you, “What do you want me to do next?”, and it is called "chevron" prompt

Solution 5 - Python

I found it to be called ' REPL'

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDumle29View Question on Stackoverflow
Solution 1 - PythonaskewchanView Answer on Stackoverflow
Solution 2 - PythonsilvadoView Answer on Stackoverflow
Solution 3 - PythonBleeding FingersView Answer on Stackoverflow
Solution 4 - PythonHossam ElshanwyView Answer on Stackoverflow
Solution 5 - PythonRohit AthithyaView Answer on Stackoverflow