What file is foo in package bar in ?

northof40 shearichard at gmail.com
Wed Aug 19 18:55:49 EDT 2009


Hi - I think this is a pretty basic question but it's never worried me
before.

To improve my skills I'm reading the source code of a library written
by someone else.

I've come across a problem doing that.

Commonly a function is called like this:

thepackage.theclass.foo

The problem is that 'theclass' is implemented in a file called
nothingliketheclass.py so finding the implemention of foo is a bit
boring.

Now I can grep for foo and depending on how common the method name is
that helps ... or not but I'm sure there must be a better way.

Given an arbitary package is there some programmatic way to 'ask' what
file the method/function is implemented in ?

thanks

R.







More information about the Python-list mailing list