

Command Line Hack: Locate the Source for any Python Module - mahipal
http://chris-lamb.co.uk/2010/04/22/locating-source-any-python-module/

======
fs111
<http://www.vim.org/scripts/script.php?script_id=910>

------
jbert
Or for any scripting language, use you can use strace.

e.g. to find CGI.pm in perl:

$ strace -e open perl -MCGI -e exit 2>&1 > /dev/null | grep CGI.pm | sed -e
's/",. _$//' -e 's/^._ "//'

/usr/share/perl/5.10/CGI.pm

Linux specific (use 'truss' on Solaris). I don't think OSX had strace like
this last time I looked, but I assume dtrace could do a similar job if there
isn't a more specific tool?

[Edit - there are literal asterisk chars in the above after the '.' chars in
the regex, but I can't see a way to include them in a HN post (backslash
escaping or HTML entities don't work)?]

------
danohuiginn
eggs won't work with this. Then again, eggs won't work with _anything_

~~~
j_baker
The pip unzip command works wonders for this. It converts a zipped egg into a
plain old package.

There are two other situations where this can cause problems:

* The module is a C extension (which might not have the __file__ attribute defined).

* The module is actually a namespace package (for example "zope" in "zope.package" and "zope.interface".

