Why functional Python matters

kosh kosh at aesaeion.com
Wed Apr 16 04:53:56 EDT 2003


On Tuesday 15 April 2003 06:45 pm, Jp Calderone wrote:
>   As many of us know, you can do this in 2.2:
>
>     reduce(int.__add__, [1, 2, 3])
>
>   Unfortunately, this breaks when ints get promoted to longs, because you
> can't pass longs to int.__add__!  Similarly:

Thankfully this is trivially solved. I just tested with python 2.3a2+

import operator
reduce(operator.__add__, range(6000000))

which gives

17999997000000L






More information about the Python-list mailing list