Silly import question (__file__ attribute)

Fredrik Lundh fredrik at pythonware.com
Thu Mar 9 17:26:32 EST 2006


"mh" wrote:

> So on most modules I import, I can access the .__file__ attribute to
> find the implementation.  ie:
> >>> import time
> >>> time.__file__
> '/data1/virtualpython/lib/python2.3/lib-dynload/timemodule.so'
> >>> import socket
> >>> socket.__file__
> '/data1/virtualpython/lib/python2.3/socket.pyc'
>
> This doesn't work on the "thread" module:
> >>> import thread
> >>> thread.__file__
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> AttributeError: 'module' object has no attribute '__file__'
>
> A few questions.  Why?  Where is thread.py or thread.so?  (I can't find
> it).

>>> import sys
>>> "thread" in sys.builtin_module_names
True

</F>






More information about the Python-list mailing list