Skip to content

Instantly share code, notes, and snippets.

@bcambel
Created July 6, 2015 08:18
Show Gist options
  • Select an option

  • Save bcambel/85792c664719b6d79f24 to your computer and use it in GitHub Desktop.

Select an option

Save bcambel/85792c664719b6d79f24 to your computer and use it in GitHub Desktop.
def get_val(inst, fields):
if isinstance(fields, basestring):
return getattr(inst,fields, "")
next_field = fields.pop(0)
next_value = getattr(inst, next_field, "")
if len(fields)>0:
return get_val(next_value, fields)
else:
return next_value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment