module file

Gabriel Genellina gagsl-py at yahoo.com.ar
Sat Jan 13 09:15:12 EST 2007


"Rob Wolfe" <rw at smsnet.pl> escribió en el mensaje 
news:87hcuv527c.fsf at smsnet.pl...
> Imbaud Pierre <pierre.imbaud at laposte.net> writes:
>
>> I am willing to retrieve the file an imported module came from;
>> module.__file__, or inspect.getfile(module) only gives me the
>> relative file name. How do I determine the path?
>
>>>> import os
>>>> os.path.abspath(module.__file__)

Note that this works only if the current dir has not changed. So it's a good 
idea to store the absolute path as early as possible (before the program 
have a chance to change the current dir)

-- 
Gabriel Genellina 






More information about the Python-list mailing list