Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > imputils - import problem modules from sys.modules

Reply
Thread Tools

imputils - import problem modules from sys.modules

 
 
Remy Cool
Guest
Posts: n/a
 
      08-21-2003
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
 
Reply With Quote
 
 
 
 
Remy Cool
Guest
Posts: n/a
 
      08-27-2003
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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
platform-specific overrides of functions and class methods (expandingon imputils demo code) lkcl Python 6 09-14-2009 11:51 PM
problem(s) with import from parent dir: "from ../brave.py import sir_robin" per9000 Python 7 02-27-2006 06:36 PM
Problem with import "from omniORB import CORBA, PortableServer" Stefan Seefeld Python 3 04-11-2005 08:54 PM
Importing modules from within other modules Tobiah Python 2 09-14-2003 09:18 PM



Advertisments