Super Tuples

Magnus L. Hetland mlh at vier.idi.ntnu.no
Mon Dec 27 11:03:09 EST 1999


Paul Prescod <paul at prescod.net> writes:

> I propose that in Python 1.6 tuples be given the demonstrated features:
> 
> >>> time = (hour=24, minute=00, second=00 )

Hm... Interesting...

[snip]

> This proposal has the following benefits:
> 
>  * it makes a nice syntax for a 1-item tuple :)

At last! ;)

>  * it makes a nice syntax for non pre-declared struct-like things

Yes... Cleaner than

  time = {'hour':24, 'minute':00, 'second':00}

Not *much* cleaner, but a bit. Of course, the tuple would be
immutable, though...

>  * it aligns better with the mathematical notion of tuple

Really? I don't think so... The mathematical notion of a tuple is that
it is an ordered set, i.e. a set where the elements each have an
index. What does that have to do with your version?

>  * the element referencing syntax is much clearer

Hm.

>  * names are easier to remember and less error prone than indexes.

In most cases - probably.

>  * it is still easy to rip them apart
> 
> This proposal may lead some to consider the unification of tuples and
> object instances, which is also a discussion worth having.

Immutable object instances? Doesn't that go against some quite basic
tenets of object oriented programming? <wink>

> 
> Opinions? Bets that Guido would apply a patch to this effect?
> 
>  Paul Prescod
> 

--

  Magnus
  Lie
  Hetland



More information about the Python-list mailing list