Thanks guys! BTW, please ignore the follow-up question there. I had written a
script earlier which had a dict like:
{'a':[x=10, y=23,..], 'b': [x=10, y=23,…],…..}
I was thinking about that and therefore the error. Apologies.
--
https://mail.python.org/mailman/listinfo/python-list
On 9/26/13 1:42 PM, Ned Batchelder wrote:
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
stuc
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
On 2013-09-26 16:42, Virendra Tripathi wrote:
> Thx Tim. Your solution works.
After Steven's reply, I recommend
dict((k,v._asdict()) for k,v in d.iteritems())
which simplifies matters.
-tkc
--
https://mail.python.org/mailman/listinfo/python-list
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.
Thanks,
Virendra
Hi MRAB,
Thanks. Learning a lot thanks to you guys.
I should have mentioned that the data is dynamic, in the sense that 'brucelee'
could be 'jackiechan' , the number of named tuples - i.e., 'brucelee(…)', could
change as well, the next time data is pulled in. The format of the data would
howev
Thx Tim. Your solution works. I am, as you can probably tell, a newbie at
Python.
--
https://mail.python.org/mailman/listinfo/python-list
On 2013-09-26 01:08, Steven D'Aprano wrote:
> On Wed, 25 Sep 2013 18:41:25 -0500, Tim Chase wrote about
> namedtuple:
>
> > While it uses the "private" member-variable "_fields", you can do
>
> It's not actually private!
>
> namedtuple is documented as an exception to the rule that methods
> st
trip...@gmail.com wrote:
> Need suggestions.
>
> Say, I have a namedtuple like this:
>
> {'a': brucelee(x=123, y=321), 'b': brucelee('x'=123, 'y'=321)
>
> I need to convert it to:
>
> {'a': {'x':123, 'y': 321},'b': {'x':123, 'y': 321}}
>
> Follow-up question --
>
> Which would be easier to w
On Wed, 25 Sep 2013 15:45:49 -0700, tripsvt wrote:
> Need suggestions.
>
> Say, I have a namedtuple like this:
>
> {'a': brucelee(x=123, y=321), 'b': brucelee('x'=123, 'y'=321)
That's not a namedtuple, that's a dict containing two namedtuples.
> I need to convert it to:
>
> {'a': {'x':123,
On 9/25/2013 9:15 PM, MRAB wrote:
On 26/09/2013 02:08, Steven D'Aprano wrote:
On Wed, 25 Sep 2013 18:41:25 -0500, Tim Chase wrote about namedtuple:
While it uses the "private" member-variable "_fields", you can do
It's not actually private!
namedtuple is documented as an exception to the ru
On 26/09/2013 02:08, Steven D'Aprano wrote:
On Wed, 25 Sep 2013 18:41:25 -0500, Tim Chase wrote about namedtuple:
While it uses the "private" member-variable "_fields", you can do
It's not actually private!
namedtuple is documented as an exception to the rule that methods
starting with a sin
On Wed, 25 Sep 2013 18:41:25 -0500, Tim Chase wrote about namedtuple:
> While it uses the "private" member-variable "_fields", you can do
It's not actually private!
namedtuple is documented as an exception to the rule that methods
starting with a single leading underscore are private. Named tup
On 9/25/13 6:45 PM, trip...@gmail.com wrote:
Need suggestions.
Say, I have a namedtuple like this:
{'a': brucelee(x=123, y=321), 'b': brucelee('x'=123, 'y'=321)
I need to convert it to:
{'a': {'x':123, 'y': 321},'b': {'x':123, 'y': 321}}
Namedtuples have a ._asdict() method. You can convert
On 25/09/2013 23:45, trip...@gmail.com wrote:
Need suggestions.
Say, I have a namedtuple like this:
{'a': brucelee(x=123, y=321), 'b': brucelee('x'=123, 'y'=321)
I assume you mean:
{'a': brucelee(x=123, y=321), 'b': brucelee(x=123, y=321)}
I need to convert it to:
{'a': {'x':123, 'y': 32
On 2013-09-25 15:45, trip...@gmail.com wrote:
> Say, I have a namedtuple like this:
>
> {'a': brucelee(x=123, y=321), 'b': brucelee('x'=123, 'y'=321)
>
> I need to convert it to:
>
> {'a': {'x':123, 'y': 321},'b': {'x':123, 'y': 321}}
While it uses the "private" member-variable "_fields", you c
Need suggestions.
Say, I have a namedtuple like this:
{'a': brucelee(x=123, y=321), 'b': brucelee('x'=123, 'y'=321)
I need to convert it to:
{'a': {'x':123, 'y': 321},'b': {'x':123, 'y': 321}}
Follow-up question --
Which would be easier to work with if I had to later extract/manipulate the
17 matches
Mail list logo