metaperl wrote: > [EMAIL PROTECTED] wrote: > > > | would use a recursive approach for this - given that you have a sort > > of recursive datastructure: > > > > py> def SetNewDataParam2(Data, NewData): > > ... if type(Data[Data.keys()[0]]) == type(dict()): > > ... SetNewDataParam2(Data[Data.keys()[0]], NewData) > > ... else: > > ... Data[Data.keys()[0]] = NewData > > ... > > Data[Data.keys()[0]] is used 3 times in the above code. Is there some > way to factor out that usage? I'm just starting python but I'm always > on the lookout for DRY :)
Bearophilehugs gave a much better answer than I did, it also takes away the need to evaluate the keys() more than one time -- http://mail.python.org/mailman/listinfo/python-list