In this post, we’ll briefly describe several sources of information about Python that are pretty useful. These sources are all available in English.
These resources should be used in tandem with a good Python learning resource like the book we’ve published. While the goal of that book is to provide you with a comprehensive introduction to programming with Python, its scope is limited, so we had to omit details in some places and refer you to further documentation, like the sources listed below, instead.
In everyday programming, it’s sometimes these details that make the difference. Here are three resources to take advantage of.
Built-In Help Function
You can call the built-in help function to start the interactive help function of the Python interpreter. Via help(), introductory text is output, followed by a command prompt. This interactive help is useful if you need to look up terms.
Terms can include keywords (e.g., for), symbols (e.g., +), modules (e.g., pprint), or topics (e.g., DEBUGGING). A list of possible search terms in these categories can be displayed using the keywords, symbols, modules, and topics commands.
If a help page was found for a term you entered, it will be displayed in a read mode. Longer texts can be scrolled. This works on Linux with the (Up) and (Down) arrow keys and on Windows with the (Space) bar. The (Q) key takes you back from the read mode to the interactive mode, which you can exit using the quit() command or the (Ctrl)+(D) shortcut.
Python's interactive help is particularly useful for quickly finding answers to interface-related questions, such as, "What functions were included in the copy module again?" or "What was the default value of the indent parameter of the pprint.pprint function again?"
Instead of starting the interactive shell of the help function, an instance such as a module or a function can also be passed to the help function. Then the corresponding help page is displayed in read mode:
>>> import pprint
Help on function pprint in module pprint:
pprint(object, stream=None, indent=1, width=80, depth=None, *, compact=False)
Pretty-print a Python object to a stream [default is sys.stdout].
Alternatively, a string can be passed that contains the search term:
>>> import copy
Help on function copy in copy:
copy.copy = copy(x)
Shallow copy operation on arbitrary Python objects.
See the module's __doc__ string for more info.
The texts displayed by Python's interactive help function are excerpts from the extensive online documentation. The latest version can be found at https://docs.python.org. There, you can switch to the documentation of an older Python version via a selection list in the upper-left-hand corner.
The online documentation is a great help for both beginners and experienced Python developers. It’s worth looking up the topics you’re interested in learning in the documentation because modules often provide a wealth of detailed functions that can’t be described comprehensively here.
The development processes for the Python language and the CPython reference interpreter are based on so-called Python Enhancement Proposals (PEPs). These are short elaborations that identify a problem in the language or interpreter, summarize possible solutions and the discussion about them, and finally propose a solution. These PEPs are the basis for discussion among Python developers for possible innovations in future versions. PEPs can be accepted or rejected after discussion has taken place, with accepted PEPs then being implemented in a future version of Python.
Check out https://www.python.org/dev/peps for a list of all PEPs that have been proposed to this date. Especially if you have detailed questions about why a function was implemented in Python in a certain way, it makes sense to read through the associated PEP. It should be noted, however, that a PEP can sometimes be very technical and may be difficult to understand even for experienced Python developers.
PEP 435 is an example of an accepted and implemented PEP. It describes the Enum data type, which has been included in the language since Python 3.4.
Note: Rather interesting are PEPs 8 and 257, which describe conventions for formatting Python code and docstrings. Although these PEPs are by no means binding, they are very popular in the community. It’s therefore worth taking a look at them.
Editor’s note: This post has been adapted from a section of the Python 3: The Comprehensive Guide by Johannes Ernesti and Peter Kaiser.