New submission from Radu Dan:
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 "./test.py", 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.
----------
components: Library (Lib)
messages: 172396
nosy: Radu.Dan
priority: normal
severity: normal
status: open
title: Allow printing of str-derived classes
type: behavior
versions: Python 2.6
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue16167>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com