Lists and Tuples

Douglas Alan nessus at mit.edu
Fri Dec 5 13:32:23 EST 2003


"Fredrik Lundh" <fredrik at pythonware.com> writes:

> Douglas Alan wrote:

>> I disagree.  You should use a tuple when you wish to not change the
>> contents once you have constructed the sequence, and otherwise you
>> should use a list.

>> Fredrik Lundh actually called me names a couple years back for
>> asserting this, but Python luminary (and rude fellow) or not, he is
>> dead wrong.

> I'm never dead wrong.

You were dead wrong to insult me in a debate over subtle programming
aesthetics, where my opinion is just as well-founded as anyone's.


>     Guido van Rossum, "State of the Python Union", March 2003:
>     http://www.python.org/doc/essays/ppt/pycon2003/pycon2003.ppt
>
>     ...
>
>     + It's a matter of user education
>
>     + Example: lists vs. tuples
>
>         this is often misrepresented as "tuple are readonly lists",
>         which is *wrong*
>
>         use cases are quite different
>
>         *but*... tuples also usable as readonly lists
>
>     ...


(0) I would never say that a tuple is a read-only list because a tuple
    *isn't* a list.  I would say that a tuple is an "immutable
    sequence", which is true by definition.  The use-cases for mutable
    sequences and for immutable sequences are obviously quite
    different because in one case you are likely going to mutate the
    sequence and in the other case, you clearly are not.

(1) Just because Guido asserts it doesn't make it true.

(2) Guido's own brother Just disagrees with him, proving that it isn't
    obvious even if you are Dutch.

(3) Guido apparently disagreed with himself when he made the container
    for excess arguments be a tuple.

(4) I have quite a few books on Python, and none of them assert that
    tuples should only be used as records, and I have seen numerous
    examples of decent code that use tuples as full-fledged immutable
    sequences to good purpose.  I posted such an example from Pmw in
    my previous message.

(5) I have never seen a *single* good reason presented anywhere for
    restricting oneself to using tuples only as records.  I have only
    seen it stated as bold assertion without support.

> I expect an apology.

Ha! The noive of some people!

|>oug




More information about the Python-list mailing list