1

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?

Telemachus
  • 19,459
  • 7
  • 57
  • 79
Erdnase
  • 750
  • 3
  • 12
  • 25

4 Answers4

3

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.

Jeremy
  • 1
  • 85
  • 340
  • 366
3

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.

cdarke
  • 42,728
  • 8
  • 80
  • 84
3

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

Daniel Casserly
  • 3,552
  • 2
  • 29
  • 60
1

>>> 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.

juhist
  • 4,210
  • 16
  • 33