Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #33240
| Date | 2012-11-13 14:53 +0100 |
|---|---|
| From | Thomas Bach <thbach@students.uni-mainz.de> |
| Subject | Re: Help building a dictionary of lists |
| References | <9f44d1de-bccf-41ad-8529-ff8a65d7e2b4@googlegroups.com> <CAN1F8qX7p_DGutu-M4QAauyRN7CoZMDdvQ130DDERwrkHtvzFQ@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3626.1352814915.27098.python-list@python.org> (permalink) |
On Mon, Nov 12, 2012 at 11:41:59PM +0000, Joshua Landau wrote:
>
> Dict comprehension:
> {i:[] for i in ["Test 1", "Test 2", "Test 3"]}
In Python 2.6 this syntax is not supported. You can achieve the same
there via
dict((i, []) for i in ['Test 1', 'Test 2', 'Test 3'])
Also have a look at ``collections.defaultdict``.
Regards,
Thomas.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Help building a dictionary of lists NJ1706 <nickj1706@googlemail.com> - 2012-11-12 14:26 -0800 Re: Help building a dictionary of lists Thomas Bach <thbach@students.uni-mainz.de> - 2012-11-13 14:53 +0100
csiph-web