Can you pass functions as arguments?

Paul Rubin http
Mon Dec 19 08:02:05 EST 2005


bokr at oz.net (Bengt Richter) writes:
> or if the OP actually wants the specific function,
>  >>> def sum100a(f): return sum(imap(f, xrange(101)))
>  ...
>  >>> sum100a(square)
>  338350

Similarly with generator comprehension, if I have the syntax right:

   def sum100c(f): return sum(f(i) for i in xrange(101))



More information about the Python-list mailing list