Re: partial sums problem

2010-09-29 Thread Chris Torek
In article kj wrote: >The following attempt to get a list of partial sums fails: > s = 0 [((s += t) and s) for t in range(1, 10)] > File "", line 1 >[((s += t) and s) for t in range(1, 10)] > ^ >SyntaxError: invalid syntax > >What's the best way to get a list of partial s

Re: partial sums problem

2010-09-28 Thread Terry Reedy
On 9/28/2010 6:57 PM, kj wrote: The following attempt to get a list of partial sums fails: s = 0 [((s += t) and s) for t in range(1, 10)] File "", line 1 [((s += t) and s) for t in range(1, 10)] ^ SyntaxError: invalid syntax What's the best way to get a list of partial su

Re: partial sums problem

2010-09-28 Thread Ian Kelly
On Tue, Sep 28, 2010 at 4:57 PM, kj wrote: > > > The following attempt to get a list of partial sums fails: > > >>> s = 0 > >>> [((s += t) and s) for t in range(1, 10)] > File "", line 1 >[((s += t) and s) for t in range(1, 10)] > ^ > SyntaxError: invalid syntax > Because in Python

Re: partial sums problem

2010-09-28 Thread Seebs
On 2010-09-28, Gary Herron wrote: > Python does have "s+=t" as a statement, and it does have list > comprehensions [... for ...] as expressions, but you cannot put a > statement inside an expression. I've inferred that, in Python, all assignments are by definition statements, rather than expre

Re: partial sums problem

2010-09-28 Thread MRAB
On 28/09/2010 23:57, kj wrote: The following attempt to get a list of partial sums fails: s = 0 [((s += t) and s) for t in range(1, 10)] File "", line 1 [((s += t) and s) for t in range(1, 10)] ^ SyntaxError: invalid syntax What's the best way to get a list of partial sum

Re: partial sums problem

2010-09-28 Thread Emile van Sebille
On 9/28/2010 3:57 PM kj said... The following attempt to get a list of partial sums fails: s = 0 [((s += t) and s) for t in range(1, 10)] File "", line 1 [((s += t) and s) for t in range(1, 10)] ^ SyntaxError: invalid syntax What's the best way to get a list of partial su

Re: partial sums problem

2010-09-28 Thread Gary Herron
On 09/28/2010 03:57 PM, kj wrote: The following attempt to get a list of partial sums fails: s = 0 [((s += t) and s) for t in range(1, 10)] File "", line 1 [((s += t) and s) for t in range(1, 10)] ^ SyntaxError: invalid syntax What's the best way to get a lis