Hi all, I found a bug in Python 2.7 involving dictionary comprehensions. I repeatedly tried to register on the Issue Tracker (http://bugs.python.org/) but never received a confirmation email, so I still can't log in and post it there. Maybe someone on this list can post it on my behalf:
>>> functions = {x : lambda y: x + y for x in xrange(10)} >>> functions[0](0) 9 >>> The expression "functions[0](0)" should return 0, not 9. It looks like the scope for variable x is shared across the entire dictionary comprehension rather than having separate scope for each generated item.
_______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com