Need clue with import hackery
Richard Jones
richard at bizarsoftware.com.au
Thu Aug 2 21:27:47 EDT 2001
On Friday 03 August 2001 11:21, Steven D. Majewski wrote:
> On Fri, 3 Aug 2001, Richard Jones wrote:
> > Hey, this is a fun conversation I'm having with myself here :)
>
> I'm glad you're enjoying it.
> I haven't been able to get a word in, myself!
Thanks for the following anyway :)
> > >>> import imp, sys
> > >>> imp.load_module('instance', None, '/tmp/roundup', ('', '', 5))
> >
> > <module 'instance' from '/tmp/roundup/__init__.pyc'>
> >
> > >>> sys.modules['roundup']
> >
> > <module 'roundup' from 'roundup/__init__.pyc'>
>
> There's also:
>
> imp.load_package( name, path )
>
> ( which doesn't appear to be in the documentation. )
And does work, and is much cleaner. Thanks!
> You might also want to add:
>
> sys.modules['instance'] = instance
No, I just need the instance in the local namespace, so this isn't necessary.
> What is 'roundup' ?
It's my implementation of Ping's software carpentry submission :)
http://roundup.sourceforge.net/
Richard
More information about the Python-list
mailing list