Raymond Hettinger added the comment:

I'm not sure a semantically neutral automatic fix is possible:

   f = lambda (a, b), c: a + b + c         # Py2.x

   f = lambda t, c: t[0] + t[1] + c        # Py3.x


The former will unpack any iterable, not just sequences:

    >>> def g():
        yield 'a'
        yield 'b'       
    >>> f(g(), 'c')
    'abc'

Also, the former will validate the number of arguments:

    >>> f((1,2,3), 4)

    Traceback (most recent call last):
      File "<pyshell#11>", line 1, in <module>
        f((1,2,3), 4)
      File "<pyshell#0>", line 1, in <lambda>
        f = lambda (a, b), c: a + b + c
    ValueError: too many values to unpack

I don't see a way to automatically include those capabilities in an automatic 
2-to-3 transformation.

----------
nosy: +rhettinger

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue16094>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to