Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'mrab': 0.04; 'library,': 0.05; 'attribute': 0.07; 'modules.': 0.07; 'statically': 0.07; 'python': 0.08; 'dynamically': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'underlying': 0.09; 'am,': 0.12; 'library': 0.13; 'always,': 0.15; '"copyright",': 0.16; '"credits"': 0.16; '"license"': 0.16; '[gcc': 0.16; 'disappeared': 0.16; 'enigma': 0.16; 'interpreter;': 0.16; 'kern': 0.16; 'linux2': 0.16; 'pathname': 0.16; 'wrote:': 0.18; 'appears': 0.19; '(most': 0.21; '(but': 0.21; 'extension': 0.21; 'dec': 0.22; 'header:In-Reply-To:1': 0.22; 'versions': 0.23; 'debian': 0.23; "skip:' 40": 0.23; 'math': 0.24; 'aug': 0.24; 'traceback': 0.24; 'loaded': 0.25; 'windows': 0.26; "i'm": 0.26; 'import': 0.27; 'tried': 0.27; 'separate': 0.28; 'interpret': 0.29; 'module.': 0.29; 'usual': 0.29; 'redhat': 0.30; 'subject:?': 0.31; 'shared': 0.31; "i've": 0.31; 'typically': 0.32; 'header:User-Agent:1': 0.33; 'header:X-Complaints-To:1': 0.33; 'instead': 0.33; 'object': 0.33; 'to:addr:python-list': 0.34; 'builds': 0.34; 'last):': 0.34; 'subject:What': 0.34; 'modules': 0.35; 'file': 0.36; 'none': 0.37; 'hat': 0.37; 'subject:skip:m 10': 0.37; 'but': 0.37; 'using': 0.38; 'linked': 0.38; 'steven': 0.38; 'received:org': 0.38; 'some': 0.38; 'several': 0.38; 'to:addr:python.org': 0.40; 'more': 0.61; 'type': 0.61; 'world': 0.62; 'received:86': 0.63; 'our': 0.64; 'believe': 0.65; '4.4.1': 0.84; 'on?': 0.84; 'eco': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Robert Kern Subject: Re: What happened to module.__file__? Date: Mon, 12 Dec 2011 16:38:00 +0000 References: <4ee54918$0$11091$c3e8da3@news.astraweb.com> <4EE557F6.5040900@mrabarnett.plus.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: host86-161-141-175.range86-161.btcentralplus.com User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:8.0) Gecko/20111105 Thunderbird/8.0 In-Reply-To: <4EE557F6.5040900@mrabarnett.plus.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 54 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1323707893 news.xs4all.nl 6902 [2001:888:2000:d::a6]:35911 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:17061 On 12/12/11 1:25 AM, MRAB wrote: > On 12/12/2011 00:21, Steven D'Aprano wrote: >> 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@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@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 "", line 1, in >> AttributeError: 'module' object has no attribute '__file__' >> >> >> What's going on? >> > The documentation for __file__ says: """The __file__ attribute is not > present for C modules that are statically linked into the interpreter; > for extension modules loaded dynamically from a shared library, it is > the pathname of the shared library file.""" > > Interestingly, none of the versions on Windows that I've tried have > that attribute for the math module. Is it platform-dependent? It is build-dependent. Windows builds typically have math and several other stdlib "extension" modules built into the PythonXY.dll . Unix builds typically, but apparently not always, leave mathmodule.so and others as separate extension modules. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco