How can I get the source code of a Python function? - Stack Overflow
Finding the source code for built-in Python functions? - Stack Overflow
How can I get the source code for Python functions? - Stack Overflow
Are there any "literary classics" of Python source code that are worth reading?
Requests is a very common answer to this question.
More on reddit.comFactsheet
Since Python is open source you can read the source code.
To find out what file a particular module or function is implemented in you can usually print the __file__ attribute. Alternatively, you may use the inspect module, see the section Retrieving Source Code in the documentation of inspect.
For built-in classes and methods this is not so straightforward since inspect.getfile and inspect.getsource will return a type error stating that the object is built-in. However, many of the built-in types can be found in the Objects sub-directory of the Python source trunk. For example, see here for the implementation of the enumerate class or here for the implementation of the list type.

I had to dig a little to find the source of the following Built-in Functions as the search would yield thousands of results. (Good luck searching for any of those to find where it's source is)
Anyway, all those functions are defined in bltinmodule.c Functions start with builtin_{functionname}
Built-in Source: https://github.com/python/cpython/blob/master/Python/bltinmodule.c
For Built-in Types: https://github.com/python/cpython/tree/master/Objects
The source code for the reference implementation of Python is available here at their GitHub mirror. However, it's worth noting that large parts of the Python language are implemented in C, including the core engine and many of the standard library libraries. Really understanding how everything is implemented under the hood requires a fair amount of C fluency.
ipython is a great tool for exploring how things work. Just add "??" after a function or other callable, and it show the code when possible, ie. when it's "pure python".
Eg:
import this
this??
If you enable the
source coderepositories in "Software sources" application (software-properties-gtk), you can download the latest python source that is related to the package:apt-get source pythonYou can do that for any ubuntu/debian package.
You can always google your way to the source code: http://www.python.org/download/releases/
Try from command line:
dpkg -L python2.7It shows you where the files are installed in your system.
Try to install the package python2.7-examples. It contains many useful examples for learning purposes.