This might seem to be too simple but it isn't explicitly mentioned anywhere.
I see the symbol ">>>"
in many Python sample codes. (Eg: scikit)
What does it mean?
This might seem to be too simple but it isn't explicitly mentioned anywhere.
I see the symbol ">>>"
in many Python sample codes. (Eg: scikit)
What does it mean?
This is the default appearance of the prompt in python
interpreter, as described in the documentation:
When commands are read from a tty, the interpreter is said to be in interactive mode. In this mode it prompts for the next command with the primary prompt, usually three greater-than signs (
>>>
); for continuation lines it prompts with the secondary prompt, by default three dots (...
).
Documentation generally follows the style of the interpreter, displaying an expression prefixed by >>>
, followed by the resulting value on the next line, with no prefix.
It's not valid Python code. You can't put it in the .py
file -- that would be a syntax error. It's like $
in bash
.
The >>>
is the standard Python prompt. It is used by IDLE and by Python interactively (just type python
on the command-line).
It is used in documentation as an "invitation to type", but also to indicate user input, doctest
is a module that uses it, for example.
In code samples the >>> indicates that this is code that you must put in your self to differentiate from the returned results. Therefore the following code sample:
>>>print "Hello World"
Hello World
Indicates that the line beginning >>> is what you must enter to receive the output of Hello World
>>> is the prompt of an interactive Python session where you can type your commands. This is why it occurs at the beginning of a line. >>> is not a valid Python operator and you shouldn't type the prompt into your programs.