Re: How find all childrens values of a nested dictionary, fast!

2010-11-06 Thread Alexander Gattin
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,

Re: How find all childrens values of a nested dictionary, fast!

2010-11-05 Thread John Ladasky
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

Re: How find all childrens values of a nested dictionary, fast!

2010-11-04 Thread Arnaud Delobelle
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],

Re: How find all childrens values of a nested dictionary, fast!

2010-11-04 Thread Peter Otten
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

Re: How find all childrens values of a nested dictionary, fast!

2010-11-04 Thread macm
aceback (most recent call last): >   File "", line 2, in > TypeError: 'int' object is not iterable > > I am trying understand this error. > > Best Regards and thanks a lot again! > > Mario > macm > > On 4 nov, 15:26, Peter Otten <__pete...@we

Re: How find all childrens values of a nested dictionary, fast!

2010-11-04 Thread macm
all last): File "", line 2, in TypeError: 'int' object is not iterable I am trying understand this error. Best Regards and thanks a lot again! Mario macm On 4 nov, 15:26, Peter Otten <__pete...@web.de> wrote: > macm wrote: > > How find all childrens

Re: How find all childrens values of a nested dictionary, fast!

2010-11-04 Thread Peter Otten
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' :{&#x

Re: How find all childrens values of a nested dictionary, fast!

2010-11-04 Thread Diez B. Roggisch
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

How find all childrens values of a nested dictionary, fast!

2010-11-04 Thread macm
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]}}},