Is this a good use for lambda
Michael Hoffman
m.h.3.9.1.without.dots.at.cam.ac.uk at example.com
Sat Dec 18 07:38:12 EST 2004
Charlie Taylor wrote:
> flow = integrate(lambda x: 2.0*pi * d(x)* v(x) * sin(a(x)),xBeg, xEnd)
def _flow_func(x):
return 2.0 * pi * d(x) * v(x) * sin(a(x))
flow = integrate(_flow_func, xBeg, xEnd)
> root = findRoot(xBeg, xEnd,
> lambda x: y2+ lp*(x-x2) -wallFunc( x )[0], tolerance=1.0E-15)
def _root_func(x):
return y2 + lp*(x - x2) - wallFunc(x)[0]
root = findRoot(xBeg, xEnd, _root_func, tolerance=1.0e-15)
I think those are much easier to follow. I find consistent punctuation
spacing helps readability too...
--
Michael Hoffman
More information about the Python-list
mailing list