Scope question
Jeff Shannon
jeff at ccvcorp.com
Thu Feb 7 14:29:41 EST 2002
Joshua Marshall wrote:
> Another possibility:
>
> from mymod import *
>
> def dosomething(x):
> import mymod
> mymod.dosomething(1000)
Nope,this does not work. As the O.P. already noted....
> > I tried mymod.dosomething(1000) but it returns an error:
> > AttributeError: 'builtin_function_or_method' object has no attribute
> > 'dosomething'
from module import * does not create a reference to module in the current
namespace, so there's nothing there to look up attributes from.
I still think that the O.P. is probably better off just using the explicit 'import
mymod; mymod.dosomething()' notation, since that is almost always the safer way to
do things, but that's a different story. :)
Jeff Shannon
Technician/Programmer
Credit International
More information about the Python-list
mailing list