Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #37640
| From | "Joseph L. Casale" <jcasale@activenetwerx.com> |
|---|---|
| Subject | RE: Dict comp help |
| Date | 2013-01-24 22:21 +0000 |
| References | <kds8o9$4v0$1@ger.gmane.org> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1022.1359066178.2939.python-list@python.org> (permalink) |
> >>> data = [{'a': 'xx', 'b': 'yy', 'c': 'zz'}, {'a': 'dd', 'b': 'ee', 'c': 'ff'}]
> >>> {d["a"]: d["c"] for d in data}
> {'xx': 'zz', 'dd': 'ff'}
Priceless,
That is exactly what I needed, for which I certainly over complicated!
Thanks everyone!
jlc
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
RE: Dict comp help "Joseph L. Casale" <jcasale@activenetwerx.com> - 2013-01-24 22:21 +0000
csiph-web