module.__path__

Ken Seehof kseehof at neuralintegrator.com
Tue Nov 27 00:44:08 EST 2001


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

If the module is an extension module, how do I find the full pathname of the source code file (preferably platform independent)?

- Ken Seehof
www.neuralintegrator.com 
kseehof at neuralintegrator.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20011126/74394de1/attachment.html>


More information about the Python-list mailing list