Tuple Format?

Alex Martelli aleaxit at yahoo.com
Sun Sep 3 03:04:34 EDT 2000


"Jürgen A. Erhard" <juergen.erhard at gmx.net> wrote in message
news:03092000.2 at sanctum.local.jae.ddns.org...
    [snip]
> People don't have a problem because they don't use it... at least *I*
> don't.  I didn't even know it's there...
>
> Or I don't have to (what use is an empty tuple?)
>
> A one-element tuple is something you *have* to deal with (at least for
> the apply(...) case, I think).

apply is a typical case that comes to mind for the empty tuple as well.

Still, there are easy syntactic alternatives:

def tup(*stuff):
    return stuff

tup() will now return (), tup("goo") will return ("goo",), and for
any number N>1 of arguments, it will be just as if the 'tup' word
was not there.  [I'd rather say 'tuple', but it's better not to
pre-empt the existing built-in function that tupleizes sequences].


Alex






More information about the Python-list mailing list