Closures in python

Ladvánszky Károly lk at
Thu Sep 18 12:14:04 CEST 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.


"Kasper B. Graversen" <kbilsted at> az alábbiakat írta a következo
hírüzenetben: 9caba98e.0309180208.692e9b68 at
> 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