module.__path__

Hans Nowak wurmy at earthlink.net
Wed Nov 28 03:29:57 CET 2001


> Ken Seehof wrote:
> 
> Why is the __file__ attribute (of a module) a relative filename rather
> than a fully qualified filename?  One would think that the __file__
> attribute might be used for the purpose of locating and opening a
> source file, right?   If somebody wants a relative filename couldn't
> they split it themselves?  By making module.__file__ relative,
> information is lost.  What was Guido thinking???  Perhaps a
> __fullpath__ should be added.
> 
> Don't tell me about the fact that .pyc files might be moved along with
> .py file from a different computer, thereby rendering the full
> pathnames incorrect.  That's a silly argument not worth addressing.
> :-)
> 
> Is there a good general way to determine the full pathname of a module
> file, or is the best approach to search sys.path for module.__file__?

Hmmm...
os.path.abspath(module.__file__) should return the absolute pathname...

--Hans



More information about the Python-list mailing list