When is a module imported from the standard library?
cary miller
cmiller at math.cudenver.edu
Wed Aug 22 17:05:15 EDT 2001
> print os.path.dirname(os.__file__)
is simplest if you only want to know about the os module. To get the
location of any module do this:
mod = os
os.path.dirname(eval(mod.__name__).__file__)
On Wed, 22 Aug 2001, Ignacio Vazquez-Abrams wrote:
> On Wed, 22 Aug 2001, cary miller wrote:
>
> > How about this?
> >
> > import os
> > mod = eval('os')
> > mod.__file__
>
> That works, although we don't need the eval() in there, I think.
>
> ---
> #! /usr/bin/python
>
> import os
>
> print os.path.dirname(os.__file__)
> ---
>
> There we go. I think that's the simplest possible implementation. Does
> everyone agree?
>
>
--
Cary Miller
Math Deparment
University of Colorado - Denver
cmiller at math.cudenver.edu
http://www-math.cudenver.edu/~cmiller
More information about the Python-list
mailing list