Tuples -- who needs 'em
m.faassen at vet.uu.nl
Wed Apr 5 08:05:57 EDT 2000
Bob Alexander <bobalex at home.com> wrote:
> I agree with this, too (noting Lisp as possibly the worst example --
> although a fine language with clear favorable influences on Python). But
> my issue is not about syntax.
> However, too bad about that nasty syntax irregularity that using parens for
> tuples presents (1,) (Couldn't resist ;-)
But tuples are nice in particular for their *syntax*. With tuples, you
return 1, 2, 3, 4
first, second, third, fourth = foo()
I think this is nice syntax. Without tuples it'd not be as nice. It's not
so much about efficiency. This pattern occurs all over Python.
> Yet the concept of array is pretty fundamental to programming. Arrays are
> usually thought of as mutable. Anyone having trouble with that concept is
> pre-beginner :-)
Anyone having trouble with the concept of immutable lists must have never
heard of functional programming?
> I'm sure tuples are not an acciental feature. And my issue comes from
> understanding, not lack of understanding.
Given the above two items, I don't think you understand tuples yet. I
consider tuples to be mostly nice syntax (with one nit, the single element
tuple). You could almost see the immutability semantics being there to
support the syntax, not the other way around. It might be possible to preserve
the nice syntax and still get rid of tuples, if you still allow this:
foo, bar, baz = [1, 2, 3]
But this is less symmetrical, and since lists are mutable, this may go wrong
far more easily.
History of the 20th Century: WW1, WW2, WW3?
No, WWW -- Could we be going in the right direction?
More information about the Python-list