Hi Everyone,
I am trying to import a package and then loop through the modules
inside the package, but I'm running to a problem. Basically:
-----
I have a package called
regression.changepassword.unittests which contains test modules.
---
In a test agent module (called agent.a), I do the following:
from regression.changepassword.unittests import *
utilities.runTests("regression.changepassword.unit tests.")
----
in the utilities.runTests, I do the following:
for id in sys.modules.keys():
if id.startswith(testtype) and sys.modules[id] != None:
print "module id is: " + `id`
---------------------------------------------------
However, the loop is never executed since it seems the list of modules
in regression.changepassword.unittests is never added to the
sys.modules. If I import the tests one by one as the follwing:
from regression.changepassword.unittests import CPWD_2
from regression.changepassword.unittests import CPWD_3
Then the program works and loops through the test modules correctly.
Am I doing something wrong? Or that is how Python works and I have to
import modules one by one. I appreciate any help that you can offer
me and thanks for your time ( I apologize if my message is too long).
Thanks,
Bardia 2 3809
On Mon, 2004-02-09 at 22:29, Dave wrote: Hi Everyone,
I am trying to import a package and then loop through the modules inside the package, but I'm running to a problem. Basically: ----- I have a package called regression.changepassword.unittests which contains test modules. --- In a test agent module (called agent.a), I do the following:
from regression.changepassword.unittests import * utilities.runTests("regression.changepassword.unit tests.")
Do you have __all__ defined in your __init__.py in
regression.changepassword.unittests?
This part of the tutorial might help: http://www.python.org/doc/current/tu...00000000000000
Rich
Rich Krauter <rm*******@yahoo.com> wrote in message news:<ma***************************************@py thon.org>... On Mon, 2004-02-09 at 22:29, Dave wrote: Hi Everyone,
I am trying to import a package and then loop through the modules inside the package, but I'm running to a problem. Basically: ----- I have a package called regression.changepassword.unittests which contains test modules. --- In a test agent module (called agent.a), I do the following:
from regression.changepassword.unittests import * utilities.runTests("regression.changepassword.unit tests.")
Do you have __all__ defined in your __init__.py in regression.changepassword.unittests?
This part of the tutorial might help: http://www.python.org/doc/current/tu...00000000000000
Rich
Hi Rich,
Thanks for your response. That was exactly what the problem was. I
should have gone through the tutorial more carefully :).
Thanks,
Bardia This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Rogue 9 |
last post by:
Hi All,
I am developing a program called oop_lb.py and it's package structure is
as below:
oop_lb
|
--------------------------------------
| | |
analysis process ...
|
by: Mark English |
last post by:
Basic problem:
If there is a C-extension module in a package and it tries to import
another python module in the same package without using the fully
qualified path, the import fails.
Config:...
|
by: Peter Tillotson |
last post by:
Hi all,
I was wondering if this is possible. In python v2.3 the import systems
was extended via PEP302 to cope with packages. *.py files in a directory
hierarchy can be imported as modules each...
|
by: Charles Krug |
last post by:
List:
I'm trying to use the example files from Programming Python, 2nd Ed.
I've copied them into c:\Python24\Examples\PP2E.
Launching any of the examples programs by themselves seems to work...
|
by: joshetomlinson |
last post by:
Hi all,
I'm new to python, and am trying to determine if it's possible to do
the following...
I have a directory structure like this, with both 'dir1' and 'dir2' in
my PYTHONPATH
dir1/...
| |
by: Martin P. Hellwig |
last post by:
Hello all,
I had some troubles in the past how to arrange my packages and modules,
because I usually don't develop my stuff in the Lib\site-packages
directory I have some troubles when importing...
|
by: Hussein B |
last post by:
Hey,
Suppose I have a Python application consists of many modules (lets say
it is a Django application).
If all the modules files are importing sys module, how many times the
sys module will be...
|
by: rs387 |
last post by:
Hi,
I've found the following behaviour on importing a variable from a
module somewhat odd. The behaviour is identical in Python 2.5 and
3.0b2.
In summary, here's what happens. I have a...
|
by: Chris Rebert |
last post by:
On Sun, Sep 28, 2008 at 7:10 AM, David Pratt <fairwinds.dp@gmail.comwrote:
Why not just catch the ImportError-s and set some variables depending
on whether you were able to import the modules,...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
|
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...
|
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 ...
| |