Re: [Tutor] function and module
"Kent Johnson" <[EMAIL PROTECTED]> wrote >> There are a couple of possibilities. >> 1) if you can import the moduile into a >>> propmpt you could >> ask abc where it's from. > print abc.__file__ should work > > __file__ is a module attribute, not a function attribute. > abc.__module__ > will give the name of the module abc is from. Oops! Thanks for the catch Kent. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] function and module
Alan Gauld wrote: > There are a couple of possibilities. > 1) if you can import the moduile into a >>> propmpt you could > ask abc where it's from. print abc.__file__ should work __file__ is a module attribute, not a function attribute. abc.__module__ will give the name of the module abc is from. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] function and module
"linda.s" <[EMAIL PROTECTED]> wrote >I am reading a sample code and want to figure out where a function > (for instance, abc) is from. > There are many lines such as > from XXX import * This is one of the chief reasons why 'from x import *' is bad practice. > Is there a way not going through all these imported modules to find > where the abc is from (by the way, the abc function is not in the > current module)? There are a couple of possibilities. 1) if you can import the moduile into a >>> propmpt you could ask abc where it's from. >>> print abc.__file__ should work 2) if the import won't work I think the next best technoque is probably to use grep, especially if the modules are all in a common directory tree. grep "def abc" */*.py Or write a short Python script to traverse the tree using os.walk and try doing 'from foo import abc' on each file HTH, -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] function and module
I am reading a sample code and want to figure out where a function (for instance, abc) is from. There are many lines such as from XXX import * Is there a way not going through all these imported modules to find where the abc is from (by the way, the abc function is not in the current module)? Thanks, Linda ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor