Find out the file name of a module from inside the module?
Michael Hudson
mwh at python.net
Mon Aug 9 09:39:17 EDT 2004
Andreas Neudecker <a.neudecker at uni-bonn.de> writes:
> Hi.
>
> I know you can read the filename of a program as sys.argv[0]. But what
> about modules? Is there a similar way to find out the file name of a
> module (called by some other module or program) from inside this
> module?
Uh, your question makes my head spin a bit, but is __file__ what you
want?
>>> import os
>>> os.__file__
'/usr/lib/python2.2/os.pyc'
Cheers,
mwh
--
Of the four project development variables - scope, cost, time and
quality - quality isn't really a free variable. The only possible
values are "excellent" and "insanely excellent", depending on
whether lives are at stake. -- Kent Beck, XP Explained
More information about the Python-list
mailing list