For a pure python module you can find the source by looking at themodule.__file__
.
The datetime module, however, is written in C, and therefore datetime.__file__
points to a .so file (there is no datetime.__file__
on Windows), and therefore, you can't see the source.
If you download a python source tarball and extract it, the modules' code can be found in the Modules subdirectory.
For example, if you want to find the datetime code for python 2.6, you can look at
Python-2.6/Modules/datetimemodule.c
You can also find the latest Mercurial version on the web at
https://hg.python.org/cpython/file/tip/Modules/_datetimemodule.c
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…