Author Radu.Dan
Recipients Radu.Dan
Date 2012-10-08.16:58:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Classes that extend the builtin 'str' cannot be printed as is, and are automatically converted to string.

#!/bin/env python
class newstring(str):
        def __str__(self):
                return self

a = newstring("hello world")
print a

Running this returns:

Traceback (most recent call last):
  File "./", line 7, in <module>
    print a
RuntimeError: print recursion

Given that instances of 'str' are immutable, I see no reason why this should not work.
Date User Action Args
2012-10-08 16:58:20Radu.Dansetrecipients: + Radu.Dan
2012-10-08 16:58:20Radu.Dansetmessageid: <>
2012-10-08 16:58:20Radu.Danlinkissue16167 messages
2012-10-08 16:58:20Radu.Dancreate