Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lambda *a, **k: a, k # does not work #46536

Closed
mark-summerfield mannequin opened this issue Mar 13, 2008 · 4 comments
Closed

lambda *a, **k: a, k # does not work #46536

mark-summerfield mannequin opened this issue Mar 13, 2008 · 4 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@mark-summerfield
Copy link
Mannequin

mark-summerfield mannequin commented Mar 13, 2008

BPO 2283
Nosy @mark-summerfield

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 = None
closed_at = <Date 2008-03-13.13:44:12.844>
created_at = <Date 2008-03-13.08:14:46.079>
labels = ['interpreter-core', 'type-bug', 'invalid']
title = 'lambda *a, **k: a, k # does not work'
updated_at = <Date 2008-03-13.13:44:12.733>
user = 'https://github.com/mark-summerfield'

bugs.python.org fields:

activity = <Date 2008-03-13.13:44:12.733>
actor = 'draghuram'
assignee = 'none'
closed = True
closed_date = <Date 2008-03-13.13:44:12.844>
closer = 'draghuram'
components = ['Interpreter Core']
creation = <Date 2008-03-13.08:14:46.079>
creator = 'mark'
dependencies = []
files = []
hgrepos = []
issue_num = 2283
keywords = []
message_count = 4.0
messages = ['63499', '63501', '63502', '63504']
nosy_count = 3.0
nosy_names = ['draghuram', 'mark', 'lorg']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue2283'
versions = ['Python 2.5', 'Python 3.0']

@mark-summerfield
Copy link
Mannequin Author

mark-summerfield mannequin commented Mar 13, 2008

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.

@mark-summerfield mark-summerfield mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Mar 13, 2008
@lorg
Copy link
Mannequin

lorg mannequin commented Mar 13, 2008

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>

@mark-summerfield
Copy link
Mannequin Author

mark-summerfield mannequin commented Mar 13, 2008

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.)

@draghuram
Copy link
Mannequin

draghuram mannequin commented Mar 13, 2008

I am closing it as invalid.

@draghuram draghuram mannequin closed this as completed Mar 13, 2008
@draghuram draghuram mannequin added the invalid label Mar 13, 2008
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

0 participants