Range Operation pre-PEP

Douglas Alan nessus at mit.edu
Fri May 11 05:40:50 EDT 2001


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

>> In what way did I misrepresent Ben's original claim?  I did not.

> you wrote:

>> Ben claimed that tuples should only be used when you know how many
>> elements there will be, and that lists should only be used for
>> homogeneous data of unknown length.

> ben didn't use "should only".  you made that up.

I did not.  It is clear from the context that this is what he
intended.  This is exactly what he said and I maintain that my
paraphrasing above is accurate:

     A list contains a variable number of homogeneous values, e.g. the
     lines of a file.  Lists are like arrays in other languages.  A
     tuple contains a fixed number of heterogeneous values where each
     element has a distinct meaning e.g. (year, month, day) for a
     date.  Tuples are like data structures or product types in other
     languages, except that their types and fields are nameless.
     Comprehensions work with a variable number of homogeneous values,
     so they produce lists.

>>> ben's right.  tuples are records, lists are containers.  anyone
>>> who has written (or studied) real-life python programs knows that.

> > That's quite the claim.  Are you saying that my Python programs are
> > not "real-life" Python programs?

> no, I'm saying that anyone who has written or studied real-life
> python programs knows that tuples don't work well as containers, and
> lists don't work well if you try to use them as records.  that's a
> fact, not an opinion.

A fact, eh?  And would you be so kind as to explain this fact.  Why
don't tuples work well as immutable containers and why don't lists
work well as mutable records?  And if there were such a thing as tuple
comprehension, what terrible things would result?

> as for your programs -- well, I haven't seen a single line of code
> from you.  if you spent more time writing and sharing code, and less
> time trolling (etc)

When have I ever "trolled"?  I have only expressed my opinion, which
is reasonably well-informed, and, I think, worth considering.

|>oug



More information about the Python-list mailing list