On Thursday, July 12, 2012 12:34:33 AM UTC+8, Ian wrote: > On Wed, Jul 11, 2012 at 4:28 AM, Colin J. Williams <c...@ncf.ca> wrote: > > I don't understand why you would expect 1, 2, 4. > > Because: > > funcs[0](2) == 2 ** 0 == 1 > funcs[1](2) == 2 ** 1 == 2 > funcs[2](2) == 2 ** 2 == 4 > > > Perhaps parentheses will help the order of evaluation: > > > > funcs = [(lambda x: x**i) for i in range( 5 )] > > > > This gives: > > 1 > > 16 > > 81 > > No, that gives 16, 16, 16 just like the original. I don't understand > why you would expect 1, 16, 81, unless you have misread the code.
I'll contribute my way of python programming: def powerb(x, b): # return x**b One functor is enough! -- http://mail.python.org/mailman/listinfo/python-list