[issue13224] Change str(class) to return only the class name

Guido van Rossum report at bugs.python.org
Wed Nov 2 18:20:00 CET 2011

Guido van Rossum <guido at python.org> added the comment:

On Wed, Nov 2, 2011 at 9:31 AM, Éric Araujo <report at bugs.python.org> wrote:
> Éric Araujo <merwok at netwok.org> added the comment:
> I’ve updated my patch to handle modules and functions too, but there is a decision to make.  The functions of built-in modules are implemented by methodobject.c, not functionobject.c (that’s for Python functions), so if we want str(sys.exc_info) to be equal to 'exc_info', then we’ll have str(dict.update) == 'update'.  Is this okay?

Hm, that doesn't seem right. Currently, str(sys.exc_info) says
<built-in function exc_info> but str(dict.update) is <built-in
function exc_info>. So the latter definitely knows that it is an
unbound method! And {}.update is <built-in method update of dict
object at 0x10040c050> so that knows it is a bound method.

I'd be okay if str(sys.exc_info) and str({}.update) were unchanged
from today and if str(dict.update) returned 'dict.update', but if
that's too complicated I'd also be okay with all three being
unchanged, thus limiting this to Python functions (and classes and


Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list