Python has a variety of command-line switches which can be passed to py. These can be found by performing py --help, which gives this output on Python 3.4:
Getting general help
If the help function is called in the console without any arguments, Python presents an interactive help console, where you can find out about Python modules, symbols, keywords and more.
Getting help about an object
The Python console adds a new function, help, which can be used to get information about a function or object.
For a function, help prints its signature (arguments) and its docstring, if the function has one.
For an object, help lists the object's docstring and the different member functions which the object has.
Opening the Python console
The console for the primary version of Python can usually be opened by typing py into your windows console or python on other platforms.
If you have multiple versions, then by default their executables will be mapped to python2 or python3 respectively.
This of course depends on the Python executables being in your PATH.
Referring to the last expression
To get the value of the last result from your last expression in the console, use an underscore _.
This magic underscore value is only updated when using a python expression that results in a value. Defining functions or for loops does not change the value. If the expression raises an exception there will be no changes to _.
Remember, this magic variable is only available in the interactive python interpreter. Running scripts will not do this.
The PYTHONSTARTUP variable
You can set an environment variable called PYTHONSTARTUP for Python's console. Whenever you enter the Python console, this file will be executed, allowing for you to add extra functionality to the console such as importing commonly-used modules automatically.
If the PYTHONSTARTUP variable was set to the location of a file containing this:
Then opening the Python console would result in this extra output:
This modified text is an extract of the original Stack Overflow Documentation created by following contributors and released under CC BY-SA 3.0