Velocity Reviews

Velocity Reviews (
-   Python (
-   -   RE: Dict comprehension help (

Joseph L. Casale 12-06-2012 04:38 AM

RE: Dict comprehension help
> {k: v for d in my_list if d['key'] == value for (k, v) in d.items()}

Ugh, had part of that backwards:) Nice!

> However, since you say that all dicts have a unique value for
> z['key'], you should never need to actually merge two dicts, correct?
> In that case, why not just use a plain for loop to search for the
> dict?

The reason is that I need several of these in an init function and they
stack up nicely where as the loops get unruly in length, but I don't

All times are GMT. The time now is 01:56 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.