[Python-Dev] re: syntax - "Aren't tuples redundant?"

Gordon McMillan gmcm@hypernet.com
Sat, 5 Feb 2000 11:11:11 -0500


Greg Wilson wrote:

> 1) As long as it's just a convention, that only a handful of people
>    strictly conform to, it's a pedagogic wart --- every Python book
>    or tutorial I've read spends at least a paragraph or two justifying
>    tuples' existence.
> 
> 2) I tried in my first class at LANL to say "tuples are like records".
>    One guy put his hand up and said, "Records that you access using
>    integer indices instead of names?  *laugh*  Well, it's good to see
>    that Fortran-66 is alive and well!" *general laughter*
> 
>    The point is a serious one --- Pascal taught us to give meaningful
>    names to the fields in structures, and then tuples take us back to
>    "oh, I think the day of the month is in the fourth field --- or is
>    it the fifth?"

When this comes up from newbies on the list (which is 
*much* less often than a number of other so-called warts), I 
explain the difference, and then say, "If you don't know which 
to use, use a list. One day it will become obvious."

Now, experience (not a priori reasoning) tells me that this is 
safe:
  x, y = tpl
and this is not:
  x, y = lst

There's not much use in arguing about it, because both require 
trust in the programmer. It's just the in the first case, you 
*can* trust the programmer, and in the second you *can't*. 
Even when the programmer is yourself.

The fact that you don't like "zen" arguments doesn't mean you 
have to make them. Don't defend it at all. Just point out that 
most Python programmers consider tuples very valuable and 
move on.

In general, it's very hard to "defend" Python on theoretical 
grounds. The newsgroup is littered with posts from OO cultists 
berating Python for it's primitive object model. They either 
move on, or shut up once they realize that Python's object 
model is a lot cleaner *in practice* than the theoretically 
correct crap they cut their teeth on.

(What astounds me is the number of functional programmers 
who are sure that Python is modeled after a functional 
language.)



- Gordon