[New-bugs-announce] [issue34443] enum repr should use __qualname__

Walter Dörwald report at bugs.python.org
Mon Aug 20 12:34:28 EDT 2018

New submission from Walter Dörwald <walter at livinglogic.de>:

The __repr__ output of an enum class should use __qualname__ instead of __name__. The following example shows the problem:

import enum

class X:
   class I:

class Y:
   class I(enum.Enum):


This prints:

<class '__main__.X.I'>
<enum 'I'>

I would have expected it to print

<class '__main__.X.I'>
<enum 'Y.I'>

or even for maximum consistency

<class '__main__.X.I'>
<enum '__main__.Y.I'>

components: Library (Lib)
messages: 323799
nosy: doerwalter
priority: normal
severity: normal
status: open
title: enum repr should use __qualname__
type: enhancement

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list