[issue45930] Lambda function bug

2021-11-29 Thread Eric V. Smith


Change by Eric V. Smith :


--
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed
type:  -> behavior

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45930] Lambda function bug

2021-11-29 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

This is known behaviour due to binding. Please see  
https://docs.python.org/3/faq/programming.html#why-do-lambdas-defined-in-a-loop-with-different-values-all-return-the-same-result

--
nosy: +xtreak

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45930] Lambda function bug

2021-11-29 Thread Valery Lovchikov


New submission from Valery Lovchikov :

Python 3.9.7 (default, Sep 10 2021, 14:59:43) 
[GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> f=[lambda x: y**x for y in [2,3]]
>>> f[0](2)
9
>>> f[1](2)
9
=
I expected 4 as a result of f[0](2), but got 9

--
messages: 407293
nosy: lvch
priority: normal
severity: normal
status: open
title: Lambda function bug
versions: Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com