Fun with sys.modules
Duncan Grisby
dgrisby at uk.research.att.com
Tue Jun 13 05:26:39 EDT 2000
In article <%Ic15.2292$c7.292284 at pouncer.easynews.com>,
Roger Upole <rupole at compaq.net> wrote:
>How about b=a ?
No, that's no good. I want the user to be able to say either "import a"
or "import b", and get the same module. I can't ask them to import
something different.
To put it in context, I'm the author of omniORBpy, a CORBA mapping for
Python. At the moment, users have to do
>>> from omniORB import CORBA
>>> orb = CORBA.ORB_init()
The recently accepted standard mapping says that they must be able to
do
>>> import CORBA
>>> orb = CORBA.ORB_init()
But I don't want to move the CORBA module out of the omniORB package,
because all sorts of things assume that that is where it is, and it
helps people who want to run in a multi-ORB environment.
So, what I want is a cheap (in space and time) way to make
omniORB.CORBA appear as if it was CORBA. It's not even possible to do
# CORBA.py
from omniORB.CORBA import *
since the CORBA module has some things prefixed with underscores which
must be available. There's quite a lot of stuff in the CORBA module,
so I'd rather not duplicate the module dictionary anyway.
Cheers,
Duncan.
--
-- Duncan Grisby \ Research Engineer --
-- AT&T Laboratories Cambridge --
-- http://www.uk.research.att.com/~dpg1 --
More information about the Python-list
mailing list