[Python-ideas] Changing str(someclass) to return only the class name
Éric Araujo
merwok at netwok.org
Fri Oct 21 16:45:44 CEST 2011
Hi everyone,
I’ve sometimes wished that str(someclass) were the natural way to get a
class name, for example when writing __repr__ methods. Guido expressed
the same wish recently, so I’ve made a patch for Python 3.3. In the
whole standard library, only one module (optparse) and three test files
(which were parsing the output of str(someclass) or using doctests) had
to be updated because of this change: http://bugs.python.org/issue13224
One can say that this change would break code and should thus be
rejected; one could argue that the previous behavior of str(someclass)
was undefined, or an implementation detail.
What say you?
Cheers
More information about the Python-ideas
mailing list