On Tue, Jul 1, 2008 at 1:46 PM, Gary Duzan <[EMAIL PROTECTED]> wrote: > In article <[EMAIL PROTECTED]>, > Neal Becker <[EMAIL PROTECTED]> wrote: >>What is a good way to emulate: >> >>from module import xxx >>where 'module' is a dynamically generated string? >> >>__import__ ('modulename', fromlist=['xxx']) >> >>seems to be what I want, but then it seems 'xxx' is not placed in globals() >>(which makes me wonder, what exactly did fromlist do?) > > You might want to read what "help(__import__)" tells you. It > sounds like what you want is:
But have you read it yourself ? > > mynamespace['xxx'] = __import__('modulename.xxx', fromlist=['xxx']) Only if modulename is actually a package, which doesn't really make sense for a "modulename". Also, fromlist doesn't need to be ['xxx'] if you want to import the submodule 'xxx' from the, now supposed, 'modulename' package, it could be anything that is not an empty list. > > Seems a bit weird to me, but that's the way it is, and I'm sure > there is a reason for it. > > Good luck. > > Gary Duzan > Motorola H&NM > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- -- Guilherme H. Polo Goncalves -- http://mail.python.org/mailman/listinfo/python-list