why cannot assign to function call

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Mon Jan 5 17:28:59 EST 2009


On Mon, 05 Jan 2009 13:21:09 -0600, Derek Martin wrote:

> Some of the comments from people include the idea that the assignment
> model is nothing special, if you've encountered any one of a dozen other
> languages.  I didn't realize programming in any of those languages was a
> prerequisite for posting questions here, or for programming with Python.

It's not. But the tone of your argument suggests you think that matching 
the named bins assignment model of the 1970s should be a prerequisite for 
all new programming languages.


There are, in general, four types of programmers new to Python. In no 
particular order:

(1) People with no programming experience at all. They won't have any 
problems with Python's assignment model because they have no preconceived 
ideas about how assignment should work.

(2) People who are used to name binding in Ruby, Java, etc. and so will 
find Python's assignment model more or less identical.

(3) Those who come from an entirely different programming model, say, 
Forth or Haskell. For them, Python's assignment model is going to be the 
least of their worries.

(4) People who are used to the named bins model from C, Pascal or 
Fortran, who will find some unusual corner cases where Python behaves 
differently to their mental model of assignment (but not for simple 
arithmetic using numbers).

Python is accessible to *all* of the above groups, although naturally 
some will need to put in more effort in different directions than others.


The tone of reproach in your posts suggests that you believe that the 
people in group 4 are more authentic programmers whose opinions are more 
correct than those in groups 1-3. I do not think there is any good reason 
to believe that group 4 is more special than the other groups.

Nor do I believe that newly created languages (as Python was, a decade 
and a half ago) should be limited to following the named bin assignment 
model for fear that C etc programmers will be put off by the (supposed) 
bizarreness of name binding. Speaking as a former Pascal programmer, I 
think most C, Fortran and Pascal programmers are far too smart for that.


>  And that speaks to my ultimate point:  Some members of the community
> seem to make assumptions about what people know or should know, or have
> experienced, and talk down to people who haven't met their expectations.
> They meet different perspectives with hostility.

In my experience, two perspectives are likely to be met with hostility:

* those which arrogantly assume that they are the One True and Correct 
perspective and all others are inferior and wrong; and

* those which ignorantly assume that they are the only perspective 
possible.


Your first post in this topic made the extraordinarily arrogant and 
incorrect claim that:

[quote]
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.
[end quote]

We can see some pretty poor assumptions right there:

* That the Python community is capable of uniformly overlooking Python's 
differences from other languages.

* That only languages "substantially taught" in undergraduate CS courses 
matter.

It seems that you don't include in the Python community all those who use 
the term "name binding" instead of variable assignment specifically 
because it gives new users a clue that Python is not the same as C.

You've also missed out on probably twenty years of CS where Java (using 
the same assignment model as Python!) has been *the* language of choice 
for undergrad CS, not to mention those introductory courses which use 
Python.

And then you're shocked, SHOCKED!!! that people respond sharply.

How different do you think the response would have been if you had said:

"What we in the Python community should try to remember is that for those 
new to the language, there can sometimes be preconceived ideas about how 
assignment works that clashes with Python's assignment model. From my own 
perspective, I found the differences between Python's name binding model 
and the named-bins model of C/Pascal/Fortran confusing at first, and to 
be honest, I still get caught by those differences. Naturally this is a 
general problem for every language, Python is hardly unique, but please 
remember not to bite the newbies just because they are still thinking in 
some other language."


-- 
Steven



More information about the Python-list mailing list