dict comprehension

  • Thread starter Daniel Fetchinson
  • Start date
D

Daniel Fetchinson

Hi folks,

There is a withdrawn PEP about a new syntax for dict comprehension:
http://www.python.org/dev/peps/pep-0274/ which says:

"Substantially all of its benefits were subsumed by generator
expressions coupled with the dict() constructor."

What does the author mean here? What's the Preferably One Way (TM) to
do something analogous to a dict comprehension?
 
P

Paul Rubin

Daniel Fetchinson said:
What does the author mean here? What's the Preferably One Way (TM) to
do something analogous to a dict comprehension?

from itertools import izip
d = dict((k,v) for k,v in izip(keys, values))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top