Can I build a dictonary with a list-comprehension?

Magnus Lie Hetland mlh at idi.ntnu.no
Mon Sep 3 16:11:20 EDT 2001


"Hans Nowak" <hnowak at cuci.nl> wrote in message
news:mailman.999504963.22471.python-list at python.org...

> Un an entirely unrelated note, maybe there should be dictionary
> comprehensions, too... :)
>
> { k,v for k,v in dict if type(v) == type("") }
>
> <ducking for cover>

I suggested this quite a while ago, but it didn't catch on.

--

  Magnus Lie Hetland         http://www.hetland.org

 "Reality is that which, when you stop believing in
  it, doesn't go away."           -- Philip K. Dick





More information about the Python-list mailing list