Python print isn't using __repr__, __unicode__ or __str__ for unicode subclass?
问题 Python print isn't using __repr__ , __unicode__ or __str__ for my unicode subclass when printing. Any clues as to what I am doing wrong? Here is my code: Using Python 2.5.2 (r252:60911, Oct 13 2009, 14:11:59) >>> class MyUni(unicode): ... def __repr__(self): ... return "__repr__" ... def __unicode__(self): ... return unicode("__unicode__") ... def __str__(self): ... return str("__str__") ... >>> s = MyUni("HI") >>> s '__repr__' >>> print s 'HI' I'm not sure if this is an accurate