On 22 July 2012 23:48, Dan Stromberg <drsali...@gmail.com> wrote: > > If a class has defined its own __repr__ method, is there a way of getting > the default repr output for that class anyway? >
For new style classes you can just call object.__repr__ e.g.: In [1]: class A(object): ...: pass ...: In [2]: class B(object): ...: def __repr__(self): ...: return 'foo' ...: In [3]: a = A() In [4]: b = B() In [5]: repr(a) Out[5]: '<__main__.A object at 0x2136b10>' In [6]: repr(b) Out[6]: 'foo' In [7]: object.__repr__(b) Out[7]: '<__main__.B object at 0x2136c10>' Oscar.
-- http://mail.python.org/mailman/listinfo/python-list