Python: How to get attribute of attribute of an object with getattr?,"from functools import reduce