Stefan Behnel <stefan...@behnel.de> writes: > Hallvard B Furuseth, 11.10.2010 23:45: >> If there were a __plain_str__() method which was supposed to fail rather >> than start to babble Python syntax, and if there were not plenty of >> Python code around which invoked __str__, I'd agree. > > Yes, calling str() "just in case" has a clear code smell. I think > that's one of the reasons why b'abc' was chosen as output of > bytes.__str__, to make it clearly visible a) what the type of the > value is, e.g. in an interactive session
Isn't that the point of repr()? > I think raising an exception in bytes.__str__ would be a horrible > thing to do. That would make it really hard and dangerous to look at > bytes objects in a debugger or interpreter session. Again, the interactive interpreter prints out the repr, and so should debuggers, etc. In fact, when the object is embedded in a container, all you get is the repr anyway. -- http://mail.python.org/mailman/listinfo/python-list