accumulator generators
- From: Cameron <cameronlarue@xxxxxxxxx>
- Date: Fri, 30 May 2008 12:50:43 -0700 (PDT)
I was reading this <a href="this http://www.paulgraham.com/icad.html">Paul
Graham article</a> and he builds an accumuator generator function in
the appendix. His looks like this:
<pre>
def foo(n):
s = [n]
def bar(i):
s[0] += i
return s[0]
return bar
</pre>
Why does that work, but not this:
<pre>
def foo(n):
s = n
def bar(i):
s += i
return s
return bar
</pre>
.
- Follow-Ups:
- Re: accumulator generators
- From: Arnaud Delobelle
- Re: accumulator generators
- From: Kirk Strauser
- Re: accumulator generators
- From: Diez B. Roggisch
- Re: accumulator generators
- Prev by Date: Re: make a string a list
- Next by Date: Re: should I put old or new style classes in my book?
- Previous by thread: python, dlls, and multiple instances
- Next by thread: Re: accumulator generators
- Index(es):
Relevant Pages
|