list vs tuple

Carl Banks idot at vt.edu
Sat Mar 31 23:09:52 EST 2001


Mike Prager <mprager at alum.mit.edu> wrote:
> I repeat that I'm not expressing an opinion about what is
> "better," just that Python's behavior is somewhat
> idiosyncratic and should carry a caution label for beginners.

It's not idiosyncratic, though.

Someone with experience only in C, Fortran, Perl, etc. might *think*
that this is idiosyncratic out of ignorance, but as he embarks on
further exploration of programming languages, he finds that assigment
by reference is common, too, especially in interpreted languages.

In fact, there are all different sorts of assignment paradigms out
there.  Some languages have assignment by copy (C, Fortran, Ada, Perl,
Basic).  There's probably one that has assignment by deep copy
somewhere.  There's assignment by reference (Python, all dialects of
LISP that I am aware of, Smalltalk, Eiffel?).  Some have different
semantics for built in types and user-defined types (Java).  I
remember seeing a language that had different operators for reference
and copy assignment, but I forget what is was.  (BTW, should Python
ever feel a need to add assignment by reference, I pray this is how it
is done.)  Some languages even have customizable assigment semantics
(C++, Ada 95).  I'm sure other paradigms exist, also.

Nevertheless, since many people learning Python have experienced only
in C, a boldface notice or two is in order.  (I believe, if one reads
carefully, that it is mentioned in passing in the Python Tutorial.)


-- 
CARL BANKS

"What is life but a series of inspired follies?"
    -- Henry Higgins in _Pygmalion_, by George Bernard Shaw



More information about the Python-list mailing list