On Sep 17, 6:11 pm, Stefano Esposito <[EMAIL PROTECTED]>
wrote:
> On Mon, 17 Sep 2007 17:49:58 +0100
>
>
>
> Paul Rudin <[EMAIL PROTECTED]> wrote:
> > Stefano Esposito <[EMAIL PROTECTED]> writes:
>
> > > Hi all
>
> > > what i'm trying to do is this:
>
> > >>>>def foo ():
> > > ...   return None
> > > ...
> > >>>>def bar ():
> > > ...   print "called bar"
> > > ...
> > >>>>def assigner ():
> > > ...   foo = bar
> > > ...
> > >>>>assigner()
> > >>>>foo()
> > > called bar
>
> > > This piece of code is not working and even trying with...
>
> > > ... How can I achieve my goal?
>
> > By adding the line:
> >    global foo
> > at the beginning of the body of assigner.
>
> This worked, thanks a lot :)
>
> --
> Stefano Esposito <[EMAIL PROTECTED]>

I got this explained to me awhile back and blogged on it here:
  
http://paddy3118.blogspot.com/2006/07/python-functions-assignments-and-scope.html

- Paddy.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to