Calling functions
Dustin J. Mitchell
dustin at v.igoro.us
Thu Oct 19 12:30:04 EDT 2006
Tommy Grav wrote:
> I have a small program that goes something like this
>
> def funcA() : pass
> def funcB() : pass
> def funcC() : pass
>
> def determine(f):
> t = f()
> return t
>
> What I would like to do is be able to
>
> n = determine(funcA)
> m = determine(funcB)
>
> But I can't really figure out how to do this (I think it is
> possible :)
Except for the spaces after the def's at the top (are those legal?), it should
work as written.
determine(funcA) results in 'f' being bound to 'funcA'; then 't = f()' results
in 'funcA' being called, and its resulting being bound to 't'; 'determine'
returns that result, and it's bound to 'n'. Is that not what you wanted?
Dustin
More information about the Python-list
mailing list