I'm stumped on how to construct a function that works on lists within lists from inside out (I guess that's how you could poorly describe it).
I'm trying to dynamically turn a list like
res = SomeDjangoQuerySet
x = ['neighborhood', ['city', ['metro', 'metro']]]
into:
getattr(getattr(getattr(getattr(res, 'neighborhood'), 'city'), 'metro'), 'metro')
AKA:
getattr(getattr(getattr(getattr(res, x[0]), x[1][0]), x[1][1][0]), x[1][1][1])
Basically, the first value will always be a string, the second value will either be a string or a list. Each list will follow this pattern (string, string OR list). The depth of lists within lists is indeterminate. The innermost first value of the getattr() will be an outside variable ('res' in this case). Any advice?