Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #53963 > unrolled thread

Re: why syntax change in lambda

Started byOscar Benjamin <oscar.j.benjamin@gmail.com>
First post2013-09-11 14:11 +0100
Last post2013-09-11 14:11 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: why syntax change in lambda Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-09-11 14:11 +0100

#53963 — Re: why syntax change in lambda

FromOscar Benjamin <oscar.j.benjamin@gmail.com>
Date2013-09-11 14:11 +0100
SubjectRe: why syntax change in lambda
Message-ID<mailman.250.1378905112.5461.python-list@python.org>
On 11 September 2013 14:03, Neal Becker <ndbecker2@gmail.com> wrote:
> In py2.7 this was accepted, but not in py3.3.  Is this intentional?  It seems to
> violate the 'principle' that extraneous parentheses are usually allowed/ignored
>
> In [1]: p = lambda x: x
>
> In [2]: p = lambda (x): x
>   File "<ipython-input-2-2b94675a98f1>", line 1
>     p = lambda (x): x
>                ^
> SyntaxError: invalid syntax

I guess it's related to the removal of auto-unpacking of arguments. i.e. in 2.x:

>>> f = lambda (x, y), z: (x, y, z)
>>> f([1, 2], 3)
(1, 2, 3)

However this was removed in 3.x so

>>> f = lambda (x, y), z: (x, y, z)
  File "<stdin>", line 1
    f = lambda (x, y), z: (x, y, z)
               ^
SyntaxError: invalid syntax

Removing that feature would allow a simplification of the lambda
syntax that would have no need to admit any kind of brackets.


Oscar

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web