Re: SyntaxError: can't assign to a function call

2006-02-28 Thread Aahz
In article <[EMAIL PROTECTED]>, Tim Roberts <[EMAIL PROTECTED]> wrote: > >One thing that can be helpful in situations like this is to remember that >+= in Python isn't quite as "special" as it is in C. So, > > f() += [4] > >is the same as > > f() = f() + [4] > >and I think you can see why that

Re: SyntaxError: can't assign to a function call

2006-02-26 Thread Tim Roberts
"Fuzzyman" <[EMAIL PROTECTED]> wrote: > >Alex Martelli wrote: >> Fuzzyman <[EMAIL PROTECTED]> wrote: >> >> > What gives ? >>... >> > >>> a = [] >> > >>> def f(): >> > return a >>... >> > >>> f() += [4] >> > SyntaxError: can't assign to function call >> >> Exactly what the error messa

Re: SyntaxError: can't assign to a function call

2006-02-26 Thread Alex Martelli
Fuzzyman <[EMAIL PROTECTED]> wrote: ... > > Exactly what the error message says: it's syntactically forbidden to > > perform any assignment on a function-call. ... > Cool, thanks. That's what I did, it's just not an error I'd seen > before. Everywhere else Python evaluates the function call a

Re: SyntaxError: can't assign to a function call

2006-02-26 Thread Fuzzyman
Alex Martelli wrote: > Fuzzyman <[EMAIL PROTECTED]> wrote: > > > What gives ? >... > > >>> a = [] > > >>> def f(): > > return a >... > > >>> f() += [4] > > SyntaxError: can't assign to function call > > Exactly what the error message says: it's syntactically forbidden to > perform an

Re: SyntaxError: can't assign to a function call

2006-02-26 Thread Lawrence Oluyede
"Fuzzyman" <[EMAIL PROTECTED]> writes: f() += [4] > SyntaxError: can't assign to function call It's obvious that that line gives you a syntax error. += is the increment operator overloaded for strings and lists and so on. It changes the lhs in place appending the rhs. In this case the

Re: SyntaxError: can't assign to a function call

2006-02-26 Thread Alex Martelli
Fuzzyman <[EMAIL PROTECTED]> wrote: > What gives ? ... > >>> a = [] > >>> def f(): > return a ... > >>> f() += [4] > SyntaxError: can't assign to function call Exactly what the error message says: it's syntactically forbidden to perform any assignment on a function-call. If you're ke

SyntaxError: can't assign to a function call

2006-02-26 Thread Fuzzyman
What gives ? >>> a = [] >>> def f(): return a >>> f() [] >>> a.append(3) >>> f() [3] >>> a += [3] >>> a [3, 3] >>> f() [3, 3] >>> f() += [4] SyntaxError: can't assign to function call >>> Fuzzyman http://www.voidspace.org.uk/python/index.shtml -- http://mail.python.org/mailman/listinf