A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2012-November/122615.html below:

[Python-Dev] chained assignment weirdity

[Python-Dev] chained assignment weirdity [Python-Dev] chained assignment weirditySerhiy Storchaka storchaka at gmail.com
Thu Nov 8 19:06:15 CET 2012
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.


More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4