squared functions--most Pythonic way?
ballabio at mac.com
Thu Jun 27 21:38:03 CEST 2002
suppose we want to define a function which, given f(x), returns
its square. There are a number of ways which come to mind, such as:
self.f = f
# with an internal named function
# with lambda
return lambda x: f(x)**2
and I'm sure people can come out with others that I didn't figure but
are obvious to any Dutchmen.
My question: is any of the above considered more Pythonic?
More information about the Python-list