Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #17000

Re: What happened to module.__file__?

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!news-transit.tcx.org.uk!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python@mrabarnett.plus.com>
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; 'library,': 0.05; 'attribute': 0.07; 'modules.': 0.07; 'statically': 0.07; 'python': 0.08; '>>>>': 0.09; 'dynamically': 0.09; 'from:addr:python': 0.09; 'library': 0.13; '"copyright",': 0.16; '"credits"': 0.16; '"license"': 0.16; '[gcc': 0.16; 'disappeared': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 0.16; 'interpreter;': 0.16; 'linux2': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'pathname': 0.16; 'received:84.92': 0.16; 'received:84.92.122': 0.16; 'received:84.92.122.60': 0.16; 'reply-to:addr:python-list': 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; 'module.': 0.29; 'usual': 0.29; 'redhat': 0.30; 'subject:?': 0.31; 'shared': 0.31; "i've": 0.31; 'header:User-Agent:1': 0.33; 'instead': 0.33; 'object': 0.33; 'to:addr:python-list': 0.34; 'received:84': 0.34; 'last):': 0.34; 'reply-to:addr:python.org': 0.34; 'subject:What': 0.34; 'modules': 0.35; 'file': 0.36; 'none': 0.37; 'hat': 0.37; 'subject:skip:m 10': 0.37; 'using': 0.38; 'linked': 0.38; 'steven': 0.38; 'some': 0.38; 'to:addr:python.org': 0.40; 'more': 0.61; 'type': 0.61; 'header:Reply-To:1': 0.71; 'reply-to:no real name:2**0': 0.72; '4.4.1': 0.84; 'on?': 0.84
X-CM-Score 0.00
X-CNFS-Analysis v=2.0 cv=ANYS+kHk c=1 sm=1 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=9jsOeB20M3cA:10 a=IRFOZeMeq5UA:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=WgUW1kd4kr3zF4-yNOcA:9 a=a6kAxa7eUTzFI1q7bV0A:7 a=wPNLvfGTeEIA:10 a=0nF1XD0wxitMEM03M9B4ZQ==:117
X-AUTH mrabarnett:2500
Date Mon, 12 Dec 2011 01:25:10 +0000
From MRAB <python@mrabarnett.plus.com>
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:8.0) Gecko/20111105 Thunderbird/8.0
MIME-Version 1.0
To python-list@python.org
Subject Re: What happened to module.__file__?
References <4ee54918$0$11091$c3e8da3@news.astraweb.com>
In-Reply-To <4ee54918$0$11091$c3e8da3@news.astraweb.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
Reply-To python-list@python.org
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3524.1323653095.27778.python-list@python.org> (permalink)
Lines 39
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1323653095 news.xs4all.nl 6896 [2001:888:2000:d::a6]:47618
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:17000

Show key headers only | View raw


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 "<stdin>", line 1, in<module>
> 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?

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

What happened to module.__file__? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-12 00:21 +0000
  Re: What happened to module.__file__? MRAB <python@mrabarnett.plus.com> - 2011-12-12 01:25 +0000
  Re: What happened to module.__file__? Robert Kern <robert.kern@gmail.com> - 2011-12-12 16:38 +0000

csiph-web