Multi-dimensional list initialization

Ian Kelly ian.g.kelly at
Wed Nov 7 22:01:19 CET 2012

On Wed, Nov 7, 2012 at 12:51 PM, Andrew Robinson
<andrew3 at> wrote:
> Interesting, you avoided the main point "lists are copied with list
> multiplication".

It seems that each post is longer than the last.  If we each responded
to every point made, this thread would fill a book.

Anyway, your point was to suggest that people would not be confused by
having list multiplication copy lists but not other objects, because
passing lists into functions as parameters works in basically the same
way.  Except that it does not work the same way, because when lists
are passed into functions, they are not copied at all.  Nor are are
any of their contents copied, lists or not.  So actually I did address
this point with the "call-by-object" tangent; I just did not
explicitly link it back to your thesis.

> But, in any event:
> Pass by value (not call by value) is a term stretching back 30 years; eg:
> when I learned the meaning of the words.  Rewording it as "Call by value" is
> something that happened later, and the nuance is lost on those without a
> very wide programming knowledge *and* age.

Potayto, potahto.  The distinction that you're describing is between
"strict" versus "non-strict" evaluation strategies.  Hinging the
distinction on the non-descriptive words "call" and "pass" is lazy
terminology that should never have been introduced in the first place.

> In any event:
> All objects in Python are based on pointers; all parameters passed to
> functions, etc, are *copies* of those pointers; (by pointer value).

No, all parameters passed to functions are *objects*.  Python itself
has no concept of pointers.  What you describe is true as an
implementation detail for CPython but not necessarily true for other
implementations, and not true at all for an abstract
(implementation-independent) view of the language.

> I made the distinction between contents of the list and the list object
> itself for that reason; I gave an explicit correction to the pass by "value"
> generalization by saying: ("the elements are passed by reference").

The elements are not passed anywhere.  Only the list object is passed
to the function, which is completely agnostic of the fact that the
list object happens to contain other objects.

More information about the Python-list mailing list