import amara def chain_attribute_call(obj, attlist): \"\"\" Allows to execute chain attribute calls \"\"\" splitted_attrs = attlist.split(\".\")
Just copying from Useful code which uses reduce() in Python:
from functools import reduce reduce(getattr, "X.Y.Z".split('.'), doc)
you could also use:
from operator import attrgetter attrgetter('x.y.z')(doc)