Parameterized Functions without Classes

Christopher T King squirrel at WPI.EDU
Fri Jun 25 15:33:42 EDT 2004


On Fri, 25 Jun 2004, Christian Tismer wrote:

> Lambdas were not the topic, since they are a deprecated
> feature, but sure it works.

Since when are lambdas deprecated? And if so, why?

IMHO, the best way to parameterize functions is with 2.4's proposed
partial() function:

def converter(factor,val):
    return val*factor

inchtocm=partial(converter,2.54)
cmtoinch=partial(converter,1/2.54)

where a handy pre-2.4 definition of partial is:

def partial(func,*args,**kw):
    return lambda *a,**k: func(*(args+a),**dict(kw.items()+k.items()))




More information about the Python-list mailing list