[Q] module name available in 'from ... import ...' statement
Carsten Haese
carsten at uniqsys.com
Mon Apr 30 20:41:12 EDT 2007
On Mon, 2007-04-30 at 16:19 -0700, kwatch wrote:
> [...]
> The goal what I want to do is to create a module by 'new' module
> and specify that module name in 'from ...' statement.
>
> ----------------------------------------
> # create a module
> import new
> foo = new.module('foo')
> foo.pi = 3.14159
> foo.x2 = lambda x: 2*x
> # specify it in 'from' statement
> from foo import pi, x2 # ImportError: No module named foo
> ----------------------------------------
Not that this can't be done, but why do you think you have to create
this 'foo' module on the fly? What is the actual problem you're trying
to solve?
-Carsten
More information about the Python-list
mailing list