New submission from John Sahr:
The following produces unexpected behavior.
I think that it should produce a list of six different lambda expressions,
but after creation, all six lambda expressions produce the same output.
It's possible that I'm missing something about Python.
##### begin example #######
from math import *
mm = []
for n in range(6):
f = lambda x: sin(n*x)
print f, f(1.0)
mm.append(f)
print '***'
for m in mm:
print m, m(1.0)
###### end example ####
----------
messages: 272454
nosy: John Sahr
priority: normal
severity: normal
status: open
title: odd behavior in creating list of lambda expressions
type: behavior
versions: Python 2.7
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue27738>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com