How can module determine its own path?

kj at
Fri Oct 30 21:35:25 CET 2009

In <7e456639-9dbb-41ba-ae36-042a034fa6a8 at> AK Eric <warpcat at> writes:

>> > 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__


>import inspect
>print inspect.getsourcefile(lambda:None)

Thank you both!


More information about the Python-list mailing list