[Python-Dev] SyntaxError: can't assign to function call

Guido van Rossum guido at python.org
Fri Aug 11 16:59:34 CEST 2006

On 8/11/06, Neal Becker <ndbecker2 at gmail.com> wrote:
> Guido van Rossum wrote:
> > On 8/10/06, James Y Knight <foom at fuhm.net> wrote:
> >> It makes just as much sense as assigning to an array access, and the
> >> semantics would be pretty similar.
> >
> > No. Array references (x[i]) and attribute references (x.a) represent
> > "locations". Function calls represent values. This is no different
> > than the distinction between lvalues and rvalues in C.
> >
> Except this syntax is valid in c++ where X() is a constructor call:
> X(whatever) += 2; is (or can be) valid c++

As I said before, C++ has a fundamentally different concept of what
assignment means; it is of no use for understanding Python's
assignment. Actually it is a big hindrance knowing about C++
assignment because it's difficult to explain to C++ users why Python
can't and won't allow assignment to be overloaded.

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-Dev mailing list