Scope question

MDK mdk at mdk.com
Thu Feb 7 10:46:53 EST 2002


"Neal Norwitz" <neal at metaslash.com> wrote in message
news:3C629FF9.CF4670FF at metaslash.com...
> 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

Neat!  Thanks, Neal.





More information about the Python-list mailing list