[Python-Dev] removing nested tuple function parameters
andrew-pythondev at puzzling.org
Sun Sep 18 04:11:44 CEST 2005
On Sat, Sep 17, 2005 at 06:20:08PM -0700, Brett Cannon wrote:
> Is anyone truly attached to nested tuple function parameters; ``def
> fxn((a,b)): print a,b``? At one of the PyCon sprints Guido seemed
> okay with just having them removed when Jeremy asked about ditching
> them thanks to the pain they caused in the AST branch. I personally
> don't see them being overly useful thanks to assignment unpacking.
> Plus I don't think they are used very much (gut feeling, though, and
> not based on any grepping).
> Would anyone really throw a huge fit if they went away? I am willing
> to write a PEP for their removal in 2.6 with a deprecation in 2.5 if
> people are up for it. Otherwise I say they should definitely go in
> Python 3.
Please keep them! Twisted code uses them in places for Deferred callbacks
that need to deal with multiple return values. For instance, the
twisted.cred.portal.Portal's login method returns Deferred that will be
called with a tuple of (interface that the avatar implements, the avatar, a
0-arg logout callable), which naturally leads to functions like:
def _cbAuthenticated(self, (iface, avatar, logout)):
Based on a quick grep, there's well over 80 uses of tuple-unpacking in
function declarations in Twisted's code base. There's almost certainly many
more outside of Twisted; I know I have some code at work that uses this.
So the short answer is: yes, we are attached to it, we will miss it. No
guarantees about throwing fits, though <wink>.
More information about the Python-Dev