On 08.11.12 03:11, Ned Batchelder wrote:
> Sorry, I should have been clearer: I was asking about weird not to say,
> "This is weird and should be changed!", but to get clarification from
> Serhiy about his statement, " It will be weird if a dict comprehension
> and a plain loop will be inconsistent." I honestly didn't know which
> behavior he considered inconsistent and therefore weird.
I was referring to two of the most popular idioms to dynamically create a dict.
d = {}
for x in a:
d[k(x)] = v(x)
d = {k(x): v(x) for x in a}
For now these methods are consistent.
I agree that the use of the side effects here is not a sensible idea, but when
such effects occur by accident, it will cause a surprise.
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com