Two variable dictionary comprehension

Nathan Ernst nathan.ernst at
Mon Apr 3 16:58:35 EDT 2017

I was a bit surprised when I looked at the language reference for 3.6.x. I
expected there'd be a direct link to comprehensions, but there's not.

You have to know what you're looking for:

6.2.5: List Displays
6.2.6: Set Displays
6.2.7: Dictionary Displays

And, then, click on the appropriate element of the sub grammar to find the
appropriate syntax.

So, it took me about 30 seconds to find the appropriate grammars, when I
expected it'd only take about 5 seconds, since I'm very familiar with the
python docs & how the grammar documentation is laid out.  I can fully
understand how someone less familiar with the documentation might have a
harder time finding the grammar than I did.

FWIW, If one was completely new to Python, even knowing the syntax is known
as a "comprehension" might be unknown. I certainly didn't know what a
comprehension was when I was learning Python. A coworker showed me, some 13
years ago.


On Mon, Apr 3, 2017 at 3:47 PM, Jerry Hill <malaclypse2 at> wrote:

> On Mon, Apr 3, 2017 at 10:30 AM, Deborah Swanson
> <python at> wrote:
> > Regular updates as the docs are updated would be a good idea too. It's
> > obvious that today's Google isn't up to it, although it occurs to me
> > that I haven't tried Google's site search on
> So, when you search google for the phrase "dict comprehension" or
> "dictionary comprehension", nothing useful comes up for you?  When I
> search either of those phrases, I get lots of useful results, all of
> which spell out how to do what you were originally asking about.  I
> know Google search results are skewed by past usage, but I'm surprised
> that you didn't find anything useful in the first couple of search
> results.
> When I do a search for 'dict comprehension' I get a boxed result
> linking to PEP 274 as the first hit, then two Stack Overflow
> questions, both of which demonstrate how to do dictionary
> comprehensions.  Following that is another link to PEP 274, a link to
> the Python docs on data structures (which does talk about dict
> comprehensions, but it's way down on the page), and then links to a
> bunch of tutorials.  If you had to judge based on my search results,
> Google does a fine job of answering python questions, at least when
> you already know the key phrase to look for.
> --
> Jerry
> --

More information about the Python-list mailing list