[issue21861] io class name are hardcoded in reprs

Josh Rosenberg report at bugs.python.org
Tue Jul 1 01:31:01 CEST 2014


Josh Rosenberg added the comment:

Is it common for C implementations to introspect to figure out their "real" name? I do this manually for reprs of my user defined classes, but I haven't noticed many built-ins that consider extensibility for the repr. Maybe I'm just not using the classes that do it or I'm overriding the repr without checking?

I just tested, and it looks like frozenset has a subclass friendly repr, while bytearray does not as of 3.4.0. Seems like it might make sense to first determine if introspection should be the default; it would mean a little code bloat every time it's done.

----------
nosy: +josh.rosenberg

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21861>
_______________________________________


More information about the Python-bugs-list mailing list