def getattribute(value, arg):
 if hasattr(value, str(arg)):
  return getattr(value, arg)
 elif (hasattr(value, 'has_key') and value.has_key(arg)):
  return value[arg]
 else:
  return settings.TEMPLATE_STRING_IF_INVALID

def getattribute ( value , arg ) : if hasattr ( value , str ( arg ) ) : return getattr ( value , arg ) elif ( hasattr ( value , 'has_key' ) and value . has_key ( arg ) ) : return value [ arg ] else : return settings . TEMPLATE_STRING_IF_INVALID
gets an attribute of an object dynamically from a string name .