Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #54844 > unrolled thread
| Started by | Ned Batchelder <ned@nedbatchelder.com> |
|---|---|
| First post | 2013-09-26 13:42 -0400 |
| Last post | 2013-09-26 13:42 -0400 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Convert namedtuple to dictionary Ned Batchelder <ned@nedbatchelder.com> - 2013-09-26 13:42 -0400
| From | Ned Batchelder <ned@nedbatchelder.com> |
|---|---|
| Date | 2013-09-26 13:42 -0400 |
| Subject | Re: Convert namedtuple to dictionary |
| Message-ID | <mailman.364.1380217388.18130.python-list@python.org> |
On 9/26/13 1:17 PM, Virendra Tripathi wrote:
> Hi Ned,
>
> Thanks. Wouldn't I have to first create a function to pull out the 'dictdict' from the data? I assume 'dictdict' refers to the 'brucelee' named tuple in the example. That's where I was getting stuck-trying to pull out the named tuples from the dict and operate on it.
I assumed you already had the data you showed. This is tupledict:
{'a': brucelee(x=123, y=321), 'b': brucelee('x'=123, 'y'=321)
Given that, you create dictdict with the line I showed:
dictdict = { k: nt._asdict() for k, nt in tupledict }
> Thanks,
>
> Virendra
Back to top | Article view | comp.lang.python
csiph-web