why cannot assign to function call

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Sat Jan 3 11:15:51 CET 2009

On Fri, 02 Jan 2009 04:39:15 -0600, 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.

What's the difference between Python and Java or C# here!?  Or are they 
also "BIZARRE"!?

> And for that matter, it's pretty unintuitive generally.

Names and objects are quite "natural" IMHO.  There are many real world 
objects which we attach one or more names to, or refer to in sequences 
like "please give me the third book on that shelve" (``shelve[2]``).

> That is, in what I'll call "normal" computer languages, a variable name
> is thought of as the address of a bin where some data is stored, and the
> name is inexorably tied to that bin.

You just call that "normal" or "intuitive" because that's what you 
learned first.

> Python is very different from this.  Names are not addresses of bins;
> they are instead simply ephemeral labels which are given to bins, where
> the bin is a Python object which contains specific data at the time of
> assignment.  A second assignment of that name doesn't change what's in
> the original bin; it actually (probably) first creates a new bin, then
> removes the name from the original bin and assigns it to the new one. 
> Intuitively, it's a bit like saying your kitchen table is no longer a
> kitchen table, and now the thing where you wash your dishes is a kitchen
> table.  It doesn't really make a lot of sense (whether or not it's so
> for good reason), and it makes describing the assignment model
> necessarily convoluted, whereas the "named bins" model from the majority
> of other languages people are likely to have been exposed to is simple
> and sensible.

I think the "bin model" is more complex because you don't just have a 
name and an object but always that indirection of the "bin".

	Marc 'BlackJack' Rintsch

More information about the Python-list mailing list