Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #53963
| References | <l0ppnd$aqs$1@ger.gmane.org> |
|---|---|
| From | Oscar Benjamin <oscar.j.benjamin@gmail.com> |
| Date | 2013-09-11 14:11 +0100 |
| Subject | Re: why syntax change in lambda |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.250.1378905112.5461.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: why syntax change in lambda Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-09-11 14:11 +0100
csiph-web