parameters: (self, obj, argument)
docstring: Get an item or attribute of an object but prefer the item.
docstring_summary: Get an item or attribute of an object but prefer the item.
docstring_tokens: Get an item or attribute of an object but prefer the item .
function: def getitem(self, obj, argument):
          """Get an item or attribute of an object but prefer the item."""
          try:
              return obj[argument]
          except (TypeError, LookupError):
              if isinstance(argument, string_types):
                  try:
                      attr = str(argument)
                  except Exception:
                      pass
                  else:
                      try:
                          return getattr(obj, attr)
                      except AttributeError:
                          pass
              return self.undefined(obj=obj, name=argument)
function_tokens: def getitem ( self , obj , argument ) : try : return obj [ argument ] except ( TypeError , LookupError ) : if isinstance ( argument , string_types ) : try : attr = str ( argument ) except Exception : pass else : try : return getattr ( obj , attr ) except AttributeError : pass return self . undefined ( obj = obj , name = argument )