You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2008-03-13.13:44:12.844>created_at=<Date2008-03-13.08:14:46.079>labels= ['interpreter-core', 'type-bug', 'invalid']
title='lambda *a, **k: a, k # does not work'updated_at=<Date2008-03-13.13:44:12.733>user='https://github.com/mark-summerfield'
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.
This is not a bug, just missing parenthesis.
>>> lambdax: x,x
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'x' is not defined
>>> lambdax: (x,x)
<function <lambda> at 0x8293e2c>
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.)
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: