[Python-Dev] SyntaxError: can't assign to function call (original) (raw)
Guido van Rossum guido at python.org
Wed Aug 9 22:41:07 CEST 2006
- Previous message: [Python-Dev] SyntaxError: can't assign to function call
- Next message: [Python-Dev] SyntaxError: can't assign to function call
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 8/9/06, Georg Brandl <g.brandl at gmx.net> wrote:
Terry Reedy wrote: > "Neal Becker" <ndbecker2 at gmail.com> wrote in message > news:ebd2sp$nnv$1 at sea.gmane.org... >> class X (object): >> pass >> >> X() += 2 >> >>> SyntaxError: can't assign to function call >> >> Suppose I actually had defined iadd for class X. Python says this >> syntax is invalid. I wish is wasn't. > > If you translate to x() = x() +2, with x called just once, it does not make > sense. You can bind to names and slots in compound objects, but not to > objects.
This is similar to x = ([1], 2) x[0] += [2] which doesn't currently work either, though it could.
No it couldn't. You can't assign to x[0]. L += R is defined as L = L.iadd(R) so L must be a valid assignment target.
-- --Guido van Rossum (home page: http://www.python.org/~guido/)
- Previous message: [Python-Dev] SyntaxError: can't assign to function call
- Next message: [Python-Dev] SyntaxError: can't assign to function call
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]