accumulator generators
Kirk Strauser
kirk at daycos.com
Fri May 30 16:04:52 EDT 2008
At 2008-05-30T19:50:43Z, Cameron <cameronlarue at gmail.com> writes:
> Why does that work, but not this:
>
> def foo(n):
> s = n
> def bar(i):
> s += i
> return s
> return bar
Assume that n is an int, making s one also. Ints are immutable; you can
only copy them. So your bar is taking s, adding i to it, then assigning the
value back to the local variable named s.
--
Kirk Strauser
The Day Companies
More information about the Python-list
mailing list