[Tutor] question: how do you pass a function as argument for application?

Daniel Yoo dyoo@hkn.EECS.Berkeley.EDU
Wed, 20 Sep 2000 02:23:19 -0700 (PDT)


On Wed, 20 Sep 2000, WIGETMAN Robert wrote:
> def toto(x):
> 	print 'toto', x
> 
> def applyAFunction(f, arg):
> 	??? f(arg)

I'm guessing that you're coming from a Scheme or Lisp background?  Your
program should work.  Here's is an interpreter session:

###
>>> def todo(x):
...     print 'todo', x
... 
>>> def applyAFunction(f, arg):
...     f(arg)
... 
>>> applyAFunction(todo, "foobarish!")
todo foobarish!
###

So this works perfectly --- what sort of error do you get when you do
this?

Good luck!