Message225141
The Python docs for the operator module include an example using map and setitem to "Build a dictionary that maps the ordinals from 0 to 255 to their character equivalents.":
d = {}
keys = range(256)
vals = map(chr, keys)
map(operator.setitem, [d]*len(keys), keys, vals)
Since map is lazy since Python 3, the dictionary d is never actually changed in this example. I'm not entirely sure what the idiomatic way to fix the example is since it strikes me as being fairly unidiomatic to begin with, but the simplest would be to call list on the result of map to force evaluation (patch attached). |
|
Date |
User |
Action |
Args |
2014-08-10 14:18:24 | mwilliamson | set | recipients:
+ mwilliamson, docs@python |
2014-08-10 14:18:24 | mwilliamson | set | messageid: <1407680304.87.0.195005785734.issue22180@psf.upfronthosting.co.za> |
2014-08-10 14:18:24 | mwilliamson | link | issue22180 messages |
2014-08-10 14:18:24 | mwilliamson | create | |
|