Hello,
On Thu, Nov 04, 2010 at 09:20:04PM +, Arnaud
Delobelle wrote:
> Tough requirement, but I think I've got it. Two
> lambdas, one reduce, one map ;)
>
> >>> a = {'a' : {'b' :{'/' :[1,2,3,4], 'ba' :{'/' :[41,42,44]}, 'bc'
> >>> :{'/':[51,52,54], 'bcd' :{'/':[68,69,66]}}},'c' :{'/' :[5,6,
On Nov 4, 10:21 am, de...@web.de (Diez B. Roggisch) wrote:
> macm writes:
> for value in d.values():
> if isinstance(value, dict):
I'm not a Python guru, but... do you care that you're breaking duck
typing here? I've had other programmers warn me against using
isinstance() for this
macm writes:
> Hi Folks
>
> How find all childrens values of a nested dictionary, fast!
>
a = {'a' : {'b' :{'/' :[1,2,3,4], 'ba' :{'/' :[41,42,44]} ,'bc'
:{'/':[51,52,54], 'bcd' :{'/':[68,69,66]}}},'c' :{'/' :[5,6,7,8]}}, 'ab' :
{'/' :[12,13,14,15]}, 'ac' :{'/' :[21,22,23]}}
macm wrote:
> About Peter script
>
> I am receiving
>
for v in f(a['a']['b']):
> ... b.extend(v)
> ...
> Traceback (most recent call last):
> File "", line 2, in
> TypeError: 'int' object is not iterable
>
> I am trying understand this error.
You are probably mixing Diez' implement
Peter
Ok! Both works fine!
Thanks a lot!
>>> for v in f(a['a']['b']):
... b.extend(v)
b
Now I will try find which script is the fast!
Regards
macm
On 4 nov, 15:56, macm wrote:
> Hi Folks
>
> Thanks a lot
>
> Script from Diez works:
>
> print list(f(a))
>
> but should be
>
> print lis
Hi Folks
Thanks a lot
Script from Diez works:
print list(f(a))
but should be
print list(f(a['a']['b']))
to fit my example.
About Peter script
I am receiving
>>> for v in f(a['a']['b']):
... b.extend(v)
...
Traceback (most recent call last):
File "", line 2, in
TypeError: 'int' obj
macm wrote:
> How find all childrens values of a nested dictionary, fast!
>
a = {'a' : {'b' :{'/' :[1,2,3,4], 'ba' :{'/' :[41,42,44]} ,'bc'
:{'/':[51,52,54], 'bcd' :{'/':[68,69,66]}}},'c' :{'/' :[5,6,7,8]}},
'ab' : {'/' :[12,13,14,15]}, 'ac' :{'/' :[21,22,23]}} a['a']
> {'c': {'/':
macm writes:
> Hi Folks
>
> How find all childrens values of a nested dictionary, fast!
There is no faster than O(n) here.
>
a = {'a' : {'b' :{'/' :[1,2,3,4], 'ba' :{'/' :[41,42,44]} ,'bc'
:{'/':[51,52,54], 'bcd' :{'/':[68,69,66]}}},'c' :{'/' :[5,6,7,8]}}, 'ab' :
{'/' :[12,13,1