Scope question

Neal Norwitz neal at metaslash.com
Thu Feb 7 10:40:41 EST 2002


MDK wrote:
> 
> I have this:
> 
> # myprog.py
> 
> from mymod import *
> 
> def dosomething(x):
>     dosomething(1000)
> 
> # End code
> 
> I want the dosomething(1000) run from the function in mymod.  However,
> instead it is running dosomething(x) in myprog.py.
> 
> Note: Changing the names of dosomething() in either module is not an option.
> (The names depicted here are not the real names in the program but have been
> changed for clarity.)
> 
> I know that one way to fix this is to change
> 
> from mymod import *
> 
> to
> 
> import mymod
> 
> But I would like to know if, without changing the import line, there is a
> way to tell Python to use the dosomething() from mymod.

from  mymod import *
mymod_dosomething = dosomething

def dosomething(x):
    mymod_dosomething(1000)

Neal



More information about the Python-list mailing list