[Python-Dev] removing nested tuple function parameters

Jim Jewett jimjjewett at gmail.com
Mon Sep 19 20:47:18 CEST 2005


Andrew Koenig wrote:

> It is possible to imagine using the feature to catch some
> type errors at the point of call, rather than having to get into the
> function itself before detecting them.

There can certainly be value in type-checking parameters and
return values, but in this case, I think the (mental) cost is too high.

With nested tuples, it hasn't actually ever helped me, but I have 
been burned by the extra fragility it introduces.  Nesting encourages
complicated parameter lists.  Nested variables can (wrongly) 
match if your data itself is made of tuples.  If the function signature 
changes, it is a lot harder to notice or track down.  Normally, I 
can defend against some of this by using keywords -- but not if the 
parameter list is nested.

Sure, it makes def __getitem__(self, (x, y)) easier -- but I don't think 
that is a good thing.  When working with someone else's code, I would 
much rather *read*

def __getitem__(self, keytuple):
    x, y = keytuple

-jJ


More information about the Python-Dev mailing list