Samuel Ainsworth added the comment:
Also applies to list comprehensions. For example,
lst = [(lambda x: x * t) for t in range(5)]
lst[0](1) # => 4
--
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.or
New submission from Samuel Ainsworth:
If we construct a dict as follows,
x = {t: lambda x: x * t for t in range(5)}
then `x[0](1)` evaluates to 4! Tested on 2.7 and 3.5.
--
messages: 260287
nosy: Samuel.Ainsworth
priority: normal
severity: normal
status: open
title: lambda in dict
New submission from Samuel Ainsworth:
Running this:
False = True
Segmentation fault: 11
gives me this:
Process: Python [17911]
Path:
/Library/Frameworks/Python.framework/Versions/3.3/Resources/Python.app/Contents/MacOS/Python
Identifier: Python
Version: 3.3.1
Changes by Samuel Ainsworth samuel_ainswo...@brown.edu:
--
type: - crash
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21433
___
___
Python-bugs