What happened to module.__file__?

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sun Dec 11 19:21:44 EST 2011


I've just started using a Debian system, instead of the usual RedHat 
based systems I'm used to, and module.__file__ appears to have 
disappeared for some (but not all) modules.

On Fedora:

[steve at orac ~]$ python -E
Python 2.6.2 (r262:71600, Aug 21 2009, 12:22:21) 
[GCC 4.4.1 20090818 (Red Hat 4.4.1-6)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import math
>>> math.__file__
'/usr/lib/python2.6/lib-dynload/mathmodule.so'



and on Debian squeeze:

steve at runes:~$ python -E
Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40) 
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import math
>>> math.__file__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute '__file__'


What's going on?



-- 
Steven



More information about the Python-list mailing list