How can module determine its own path?

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Sat Oct 31 02:10:23 EDT 2009


En Fri, 30 Oct 2009 20:40:59 -0300, Stef Mientki <stef.mientki at gmail.com>
escribió:
> Robert Kern wrote:
>> On 2009-10-30 12:19 PM, kj wrote:

>>> How can a module determine the path of the file that defines it?
>>> (Note that this is, in the general case, different from sys.argv[0].)
>>
>> __file__
>>
> but for modules launched with execfile, __file__ doesn't exists.

Remember that execfile just executes the file contents, it does not create
a new module nor interacts with the module management.
"modules launched with execfile" has no meaning.

-- 
Gabriel Genellina




More information about the Python-list mailing list