Playing with modules

jjcassidy at gmail.com jjcassidy at gmail.com
Fri Feb 24 20:52:52 EST 2006


> You're going to have to create the home.base module somewhere. If you
> want to put in that some code that basically imports another module's
> namespace into the home.base module's namespace, then that may do what
> you want.

Thanks, Jonathon, but I think I've tried what you are saying. I've
tried doing this a couple different ways.

I suppose that what I could do is go somewhat explicit, and instead of
trying to exploit the natural import language, create a method for this
such as home.use('base') which could use even use the tracestack, get
the current frame's globals and stick the entry { 'base': <module
'cassidy.base' from 'C:\Dev\Python24\lib\cassidy\base\__init__.pyc'> }
into the currect scope and just make that part of the "API".

But I was wondering whether I could fool or "backend" the normal import
mechanism. Even in Java, I can write my own class loader which can
quick compile Java snippets and load the anonymous byte code.

Thanks, 

John




More information about the Python-list mailing list