How do I find the location of Python module sources?

Daryl Spitzer

How do I learn where the source file for a given Python module is installed? Is the method different on Windows than on Linux?

I'm trying to look for the source of the datetime module in particular, but I'm interested in a more general answer as well.

Moe

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do I find the location of Python module sources while I can not import it?

From Dev

How do I get the location of the entry module in python?

From Dev

How do I find all of my software sources?

From Dev

How do I find all of my software sources?

From Dev

How to find a module's location

From Java

How do I find the location of my Python site-packages directory?

From Dev

How can I find the function of a python module?

From Dev

how do i find the location where a Spirit parser matched?

From Dev

how do I find the location of mysql drivers on CentOS 7?

From Dev

How do I find out programmatically which mode of Location is turned on?

From Dev

How do I find the location of a particular string in a string array?

From Dev

How do I install a Python module?

From Java

How do I unload (reload) a Python module?

From Dev

How do I install the python pymorph module?

From Java

How do I find the Go module source cache?

From Dev

Given a function object, how do I find its name and module?

From Dev

How do i find out what pulseaudio module does what?

From Dev

How do i change the location directory of python open document?

From Dev

How do i change the location directory of python open document?

From Dev

How do i change my location sending a request in python

From Dev

How do I find the total (Python)

From Dev

How do I do image plots in the gnuplot module for python?

From Dev

How do I do image plots in the gnuplot module for python?

From Dev

How can I find out what package that a python module belongs to?

From Dev

Find a module location in Joomla

From Java

How do I resolve "cannot find module for path X" importing a local Go module?

From Dev

How do I find the location of all files with a particular name whose content contains a particular string?

From Dev

How to find the path of a module in python

From Dev

How do I 'force' python to use a specific version of a module?

Related Related

  1. 1

    How do I find the location of Python module sources while I can not import it?

  2. 2

    How do I get the location of the entry module in python?

  3. 3

    How do I find all of my software sources?

  4. 4

    How do I find all of my software sources?

  5. 5

    How to find a module's location

  6. 6

    How do I find the location of my Python site-packages directory?

  7. 7

    How can I find the function of a python module?

  8. 8

    how do i find the location where a Spirit parser matched?

  9. 9

    how do I find the location of mysql drivers on CentOS 7?

  10. 10

    How do I find out programmatically which mode of Location is turned on?

  11. 11

    How do I find the location of a particular string in a string array?

  12. 12

    How do I install a Python module?

  13. 13

    How do I unload (reload) a Python module?

  14. 14

    How do I install the python pymorph module?

  15. 15

    How do I find the Go module source cache?

  16. 16

    Given a function object, how do I find its name and module?

  17. 17

    How do i find out what pulseaudio module does what?

  18. 18

    How do i change the location directory of python open document?

  19. 19

    How do i change the location directory of python open document?

  20. 20

    How do i change my location sending a request in python

  21. 21

    How do I find the total (Python)

  22. 22

    How do I do image plots in the gnuplot module for python?

  23. 23

    How do I do image plots in the gnuplot module for python?

  24. 24

    How can I find out what package that a python module belongs to?

  25. 25

    Find a module location in Joomla

  26. 26

    How do I resolve "cannot find module for path X" importing a local Go module?

  27. 27

    How do I find the location of all files with a particular name whose content contains a particular string?

  28. 28

    How to find the path of a module in python

  29. 29

    How do I 'force' python to use a specific version of a module?

HotTag

Archive