Closures in python

Ladvánszky Károly lk at digicart.hu
Thu Sep 18 06:14:04 EDT 2003


Try this.

def f(n):
  return n*2

def t(fnc_prm, n):
  return fnc_prm(n)

t(f, 2)

I hope it helps.

Károly

"Kasper B. Graversen" <kbilsted at it-c.dk> az alábbiakat írta a következo
hírüzenetben: 9caba98e.0309180208.692e9b68 at posting.google.com...
> Having played with Smalltalk for the past month, I'm getting used to
> passing code as arguments to methods... how easy is it to do this in
> python? I haven't seen any recent postings on this subject here...
>
> \kasper






More information about the Python-list mailing list