why cannot assign to function call

sturlamolden sturlamolden at yahoo.no
Tue Jan 6 18:18:10 CET 2009

On Jan 2, 5:43 pm, Steve Holden <st... at holdenweb.com> wrote:
> Derek Martin wrote:
> > On Tue, Dec 30, 2008 at 02:21:29PM +0000, John O'Hagan wrote:
> [...]
> > What the Python community often overlooks, when this discussion again
> > rears its ugly head (as it seems to every other hour or so), is that
> > its assignment model is BIZARRE, as in it's conceptually different
> > from virtually all other languages substantially taught in
> > undergraduate computer science programs.  And for that matter, it's
> > pretty unintuitive generally.
> I'd definitely argue against bizarre. It's actually very easy to
> understand, and Python is by no means the only language to have used it.

A statement like

f(x) = 1

has no meaning in most languages - including Python, C and Java.

C++ references allows operator= to be overloaded. It is one of few
languages where a statement like 'f(x) = 1;' maybe meaningful. But C++
references are addresses (pointers in disguise), not names. The = is
Python's name binding operator. Python is similar to Java in this
respect. If anything is bizarre here, it is C++ references.

P.S. The C statement '*f(x) = 1;' does have meaning, but 'f(x) = 1;'
do not. But in the former case, one is not assigning to the return
value. Python and Java do not have raw pointers like C.

More information about the Python-list mailing list