How to assign a function to another function

Stefano Esposito stefano.esposito87 at gmail.com
Mon Sep 17 12:23:59 EDT 2007


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
>>>def assigner (a, b):
...	a = b
...
>>>assigner(foo, bar)
>>>foo()

isn't working. How can I achieve my goal?

Thanks for your help! :)
-- 
Stefano Esposito <stefano.esposito87 at gmail.com>



More information about the Python-list mailing list