Daily Shaarli

All links of one day in a single page.

June 28, 2009

Recursive getattr/setattr « Mousebender

You can make a more compact implementations with help of the reduce builtin function:

def rec_getattr(obj, attr):
return reduce(getattr, attr.split(”.”), obj)