Suppose we have an advanced class that implements a lot or special functions, including
__getattr__
__getitem__
__iter__
__repr__
__str__
An example would be ParseResults class in pyparsing.py.
Removing the (no doubt important) details, the constructor looks like this
def __init__( ... ):
        self.__doinit = False
        self.__name = None
        self.__parent = None
        self.__accumNames = {}
        self.__asList = asList
        self.__modal = modal
        self.__toklist = toklist[:]
        self.__tokdict = dict()
And then we have __getattr__ and __getitem__:
def __getattr__( self, name ):
    try:
        return self[name]
    except KeyError:
        return ""
def __getitem__( self, i ):
    if isinstance( i, (int,slice) ):
        return self.__toklist[i]
    else:
        if i not in self.__accumNames:
            return self.__tokdict[i][-1][0]
        else:
            return ParseResults([ v[0] for v in self.__tokdict[i] ])
I'd like to be able to do something like print res.__tokdict in the console, but that would not work: it prints empty string, as the __getattr__ implementation should.
How do I work around this and see the actual data in the object?
