Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #53961 > unrolled thread
| Started by | Neal Becker <ndbecker2@gmail.com> |
|---|---|
| First post | 2013-09-11 09:03 -0400 |
| Last post | 2013-09-12 00:09 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
why syntax change in lambda Neal Becker <ndbecker2@gmail.com> - 2013-09-11 09:03 -0400
Re: why syntax change in lambda Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-09-12 00:09 +0000
| From | Neal Becker <ndbecker2@gmail.com> |
|---|---|
| Date | 2013-09-11 09:03 -0400 |
| Subject | why syntax change in lambda |
| Message-ID | <mailman.249.1378904645.5461.python-list@python.org> |
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
[toc] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2013-09-12 00:09 +0000 |
| Message-ID | <5231064c$0$29988$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #53961 |
On Wed, 11 Sep 2013 09:03:49 -0400, Neal Becker 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
It is not specific to lambda, it has to do with the removal of argument
unpacking in function argument lists:
# allowed in Python 2, not in Python 3
def f(a, b, (c, d), e):
pass
In Python 3, the parser appears to disallow any extra parentheses inside
the parameter list, even if strictly speaking they don't do anything:
py> def f(a, b, (c), d, e):
File "<stdin>", line 1
def f(a, b, (c), d, e):
^
SyntaxError: invalid syntax
--
Steven
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web