[Types-sig] tuples (was: New syntax?)

Tony Lownds tony@metanet.com
Mon, 20 Dec 1999 11:37:22 -0800 (PST)

On Mon, 20 Dec 1999, Guido van Rossum wrote:
> The only reason not to switch to tuples is backwards compatibility --
> in particular there is a lot of code (e.g. in the std library) that
> creates new arg lists by adding tuples to *args.  This could be solved
> by allowing + to operate on a mix of lists and tuples.  I think the
> result should yield a list.

There would be forwards compatability issues too; people might starting

class A:
  def foo(self, *args):
    args[:0] = [self]
    apply(foo, args)

  def bar(self, *args):

This code would not work on existing Pythons.

If this change would just be because of a lack of a way to say, a tuple of
any length of type A, then may I suggest "tuple of A", e.g.

def foo(*args: tuple of float) -> (float, float):
  # return the median and mode of its arguments