473,325 Members | 2,608 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

imputils - import problem modules from sys.modules

Hello,

I've created an archive import class (with the help of importers.py from the
python /demo/imputil dir) which imports packages and modules from a
dictionary. So far so good.

The problem is that every import statement after the code:

imputil.ImportManager().install()
sys.path.insert(0, DictImporter(archive))
sys.path.insert(0, imputil.BuiltinImporter())

tries to import from the dictionary and doesn't use the modules that were
imported before.

For example, I would like to use os in a module that's stored in the
dictionary. The import os statement tries to import os from the dictionary
and does not 'use' the already imported os module that is in the modules
list.

Is it possible to get access to both, already loaded modules in the modules
list and modules in the dictionary?

Regards,
Remy Cool
Jul 18 '05 #1
1 1750
Problem solved!!!

Switched to python 2.3 and created a class using the brand new
sys.path_hooks.

See python PEP302 for more info on this subject.

Remy
Hello,

I've created an archive import class (with the help of importers.py from
the python /demo/imputil dir) which imports packages and modules from a
dictionary. So far so good.

The problem is that every import statement after the code:

imputil.ImportManager().install()
sys.path.insert(0, DictImporter(archive))
sys.path.insert(0, imputil.BuiltinImporter())

tries to import from the dictionary and doesn't use the modules that were
imported before.

For example, I would like to use os in a module that's stored in the
dictionary. The import os statement tries to import os from the dictionary
and does not 'use' the already imported os module that is in the modules
list.

Is it possible to get access to both, already loaded modules in the
modules list and modules in the dictionary?

Regards,
Remy Cool


Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: John Roth | last post by:
I've found a case where it seems that Python is importing two copies of a module without any reason or indication. It took me a while to verify that this is what is occuring: I had to write a...
13
by: Robin Haswell | last post by:
Hey people I'm an experience PHP programmer who's been writing python for a couple of weeks now. I'm writing quite a large application which I've decided to break down in to lots of modules...
4
by: Christoph Zwerschke | last post by:
I'm currently investigating a problem that can hit you in TurboGears when Kid template modules are reloaded in the background, because in certain situations, global variables suddenly are set to...
3
by: Mohamed Yousef | last post by:
Hello , The problem I'm asking about is how can imported modules be aware of other imported modules so they don't have to re-import them (avoiding importing problems and Consicing code and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.