[New-bugs-announce] [issue19011] Enum should have a __getattr__ that makes all the instances available from an instance

Chris Lambacher report at bugs.python.org
Fri Sep 13 18:55:43 CEST 2013


New submission from Chris Lambacher:

The use case for this is that when you are in a template and you want to use the Enum instances in a conditional, then you need to pass the Enum class to the template or start using someenumvariable.__class__.someenumvalue. Instead it would be useful to be able to do someenumvariable.someenumvalue. Implimenting as __getattr__ on enum class allows real attributes to take precedence and also allows for overriding of behaviour in child classes.

----------
components: Library (Lib)
files: getattr_for_enum_class.patch
keywords: patch
messages: 197611
nosy: lambacck
priority: normal
severity: normal
status: open
title: Enum should have a __getattr__ that makes all the instances available from an instance
versions: Python 3.4
Added file: http://bugs.python.org/file31745/getattr_for_enum_class.patch

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


More information about the New-bugs-announce mailing list