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.

The assignment to foo in the body of assigner makes a local (to the
function) variable called foo and assigns bar to it.

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

Reply via email to