I believe you've overriden unicode.__str__ as you expect. class S(str): def __str__(self): return "S.__str__" class U(unicode): def __str__(self): return "U.__str__" print str(S()) print str(U()) This script prints: S.__str__ U.__str__ Regards, -- KAJIYAMA, Tamito <RD6T-KJYM at asahi-net.or.jp> >Is this a bug? If not, how do I override __str__ on a unicode derived class? > >class S(str): > def __str__(self): return '__str__ overridden' > >class U(unicode): > def __str__(self): return '__str__ overridden' > def __unicode__(self): return u'__unicode__ overridden' > >s = S() >u = U() > >print 's:', s >print "str(s):", str(s) >print 's substitued is "%s"\n' % s >print 'u:', u >print "str(u):", str(u) >print 'u substitued is "%s"' % u > >----------------------------------------------------- > >s: __str__ overridden >str(s): __str__ overridden >s substitued is "__str__ overridden" > >u: >str(u): __str__ overridden >u substitued is "" > >Results are identical for 2.4.2 and 2.5c2 (running under windows). > > Mike
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