new python syntax: concatenation of functions
Daniel Dittmar
daniel.dittmar at sap.com
Thu Mar 11 07:55:26 EST 2004
Radovan Garabik wrote:
> or, without leaving ascii:
>
> def (x)composition(y):
> return lambda par: x(y(par))
> print (a composition b)(x)
or without leaving Python
class Composition:
def __init__ (self, outer, inner):
self.outer = outer
self.inner = inner
def __call__ (self, *args):
return self.outer (self.inner (*args))
def __str__ (self):
return '%s ° %s' % (self.outer, self.inner)
Daniel
More information about the Python-list
mailing list