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).
thanks
matt 3 3229
On Thu, Mar 09, 2006 at 02:04:45PM -0800, 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).
Python 2.4.1 (#2, Mar 30 2005, 21:51:10)
[GCC 3.3.5 (Debian 1:3.3.5-8ubuntu2)] on linux2
Type "help", "copyright" , "credits" or "license" for more information. import sys import thread sys.modules['thread']
<module 'thread' (built-in)> thread
<module 'thread' (built-in)> ^D
sprat:~# cd ~/src/python-head/Modules/
sprat:~/src/python-head/Modules# ls thread*
threadmodule.c threadmodule.o
It is a built-in module so it doesn't have a .so (dll) or .py file
to mention.
-Jack
"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_mod ule_names
True
</F>
On Thu, 09 Mar 2006 17:25:20 -0500, Jack Diederich wrote: It is a built-in module so it doesn't have a .so (dll) or .py file to mention.
Wouldn't it make sense for module.__file__ to be set to None rather than
completely missing in this case?
--
Steven. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Stian Søiland |
last post by:
all examples performed with:
Python 2.3+ (#2, Aug 10 2003, 11:09:33)
on linux2
(2, 3, 0, 'final', 1)
This is a recursive import:
|
by: Simon Dahlbacka |
last post by:
I recently had a problem caused by path extension (sys.path.extend) so
that a module/package got imported twice both as foo.module and
module, which caused all sorts of problems.
Naturally best is to use absolute paths and avoid path extension, but
this cannot be done in all places.
Anyway, I'd like to prevent such things from happening again by
inserting an __import__ hook to catch these kinds of problems.
|
by: unexpected |
last post by:
Hey guys,
I'm having problems importing a file into my python app. Everytime I
try to define the object specified by this file, i.e,
test = Test(),
It raises an ImportError exception: ImportError: cannot import name
Test.
|
by: dwelch91 |
last post by:
Hi, c.l.p.'ers-
I am having a problem with the import of xml.parsers.expat that has
gotten me completely stumped. I have two programs, one a PyQt program
and one a command line (text) program that both eventually call the
same code that imports xml.parsers.expat. Both give me different
results...
The code that gets called is (print statements have been added for
debugging):
|
by: Alan Isaac |
last post by:
Are relative imports broken in 2.5?
Directory ``temp`` contains::
__init__.py
test1.py
test2.py
File contents:
__init__.py and test2.py are empty
test1.py contains a single line::
| |
by: John Boy |
last post by:
First post and very much a newbie to Python. Have 2.5 on Linux (GG). I
think I have set up PYTHONPATH correctly in that I can import a module
apply_bp and it complains about line 20 in apply_bp which is:
import sys, aipy, numpy, os
At the interpreter prompt, however, I can import sys, numpy etc. and
can do dir() and see the entry points so I think my overall
installation is OK.
|
by: Gruik |
last post by:
Hi people,
I'm currently working on python embedding with C++. My goal is that
the C++ part handle files writing/reading so that the Python part only
works with buffers.
I succeeded in buffer exchanges. The problem is that some of the files
I read/write are python files so that, before embedding, I imported
them as modules when I needed them.
|
by: Stef Mientki |
last post by:
hello,
The import statement "import sqlite3" gives the error given below.
In simple programs, the import statement (sometimes) succeed,
and I can indeed access the database.
So I guess there is some conflict with another part of my program,
but as the program is rather large (and dynamic) it's not easy to
isolate the problem.
Does anyone has a clue how to trace this kind of problem ?
|
by: Gary Herron |
last post by:
Dan Yamins wrote:
Because loading (and reloading) assigns values to variables (called
binding a value in Python), but does not go on a hunt to find variables
to *unbind*. Once a variable is bound to a value, it stays bound until
something unbinds or rebinds it, and module loading does no such thing.
But in fact you did *not* delete the module from memory. A module
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |