[issue34443] enum repr should use __qualname__

Serhiy Storchaka report at bugs.python.org
Tue Sep 11 10:18:14 EDT 2018


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

I think using more longer name in repr and/or str for *instances* of enum classes is not good idea. They are already verbose, and this will make them more verbose.

Actually in some cases when enum instances are exposed as module globals, I would want to make them including the module name instead of the enum class name. For example:

>>> import socket
>>> socket.AF_UNIX
<AddressFamily.AF_UNIX: 1>
>>> print(socket.AF_UNIX)
AddressFamily.AF_UNIX

"socket.AF_UNIX" instead of "AddressFamily.AF_UNIX" would look better to me.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34443>
_______________________________________


More information about the Python-bugs-list mailing list