This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2008年03月13日 08:14 by mark, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Messages (4) | |||
|---|---|---|---|
| msg63499 - (view) | Author: Mark Summerfield (mark) * | Date: 2008年03月13日 08:14 | |
According to the docs lambda can handle the same parameter list as can
def. But this does not appear to be the case as the following (both
2.5.1 and 30a3) shows:
>>> def f(*a, **kw): return a, kw
>>> f(1,2,a=3,b=4)
((1, 2), {'a': 3, 'b': 4})
>>> A = lambda *a: a
>>> A(1,2)
(1, 2)
>>> K = lambda **k: k
>>> K(a=1,b=2)
{'a': 1, 'b': 2}
>>> X = lambda *a, **k: a, k
Traceback (most recent call last):
File "<pyshell#17>", line 1, in <module>
X = lambda *a, **k: a, k
NameError: name 'k' is not defined
So either this is an interpreter bug, or a doc bug.
|
|||
| msg63501 - (view) | Author: Imri Goldberg (lorg) | Date: 2008年03月13日 11:18 | |
This is not a bug, just missing parenthesis. >>> lambda x: x,x Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'x' is not defined >>> lambda x: (x,x) <function <lambda> at 0x8293e2c> |
|||
| msg63502 - (view) | Author: Mark Summerfield (mark) * | Date: 2008年03月13日 11:47 | |
On 2008年03月13日, Imri Goldberg wrote: > Imri Goldberg <lorgandon@gmail.com> added the comment: > > This is not a bug, just missing parenthesis. > > >>> lambda x: x,x > > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > NameError: name 'x' is not defined > > >>> lambda x: (x,x) > > <function <lambda> at 0x8293e2c> Yes, sorry. (But I don't seem to have the ability to make the bug resolved or deleted.) |
|||
| msg63504 - (view) | Author: Raghuram Devarakonda (draghuram) (Python triager) | Date: 2008年03月13日 13:44 | |
I am closing it as invalid. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:31 | admin | set | github: 46536 |
| 2008年03月13日 13:44:12 | draghuram | set | status: open -> closed resolution: not a bug messages: + msg63504 nosy: + draghuram |
| 2008年03月13日 11:47:48 | mark | set | messages: + msg63502 |
| 2008年03月13日 11:18:35 | lorg | set | nosy:
+ lorg messages: + msg63501 |
| 2008年03月13日 08:14:59 | mark | set | type: behavior |
| 2008年03月13日 08:14:46 | mark | create | |