[issue25548] Show the address in the repr for class objects

ppperry report at bugs.python.org
Thu May 19 15:09:37 EDT 2016


ppperry added the comment:

I don't quite get why the memory address is helpful, but you could work around this using a custom metaclass:

    class IdMeta(type):
        def __repr__(cls):
            return super().__repr__()[:-1] + " at 0x%x>"%id(cls)
    class IdInRepr(metaclass=IdMeta):pass

`IdInRepr` and all its subclasses will then have the memory address in their representation:

  <class 'module.name' at address>

----------
nosy: +ppperry

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


More information about the Python-bugs-list mailing list