This phenomenon is not really specific to repr(). It occurs with new-style classes when methods are assigned. Example: class A(object): def __repr__(self): return 'abc' >>>a = A() >>>a.__repr__ = lambda: 'abc' >>>repr(a) 'abc' >>>a.__repr__() '123' Whenever the method is accessed by Python code it sees the assigned method in the object's __dict__. Builtins like repr(), iter() etc, see the original class method. With classic objects both Python and C code see the assigned function. This is bug #515336 on sourceforge. Is anyone aware of any other cases where C code and Python code don't see objects the same way? Oren
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4