On Sun, Sep 22, 2013 at 10:41 PM, Zero Piraeus <z...@etiol.net> wrote:
> I may be misunderstanding the use case given in the issue, > To clarify the use case, since it is my bug, this is so that the enum values are always available for comparison. The exact use case is in Django templates where a value comes from the database. If you want to compare you either have to use __class__ which I would say is a code smell, or you have to provide the Enum class. The code we are using for this is open source http://github.com/tindie/django-tidyenum. An example of how this will be used in practice is: {% if object.state == object.state.completed %} some html {% endif %} > but it seems > to me that having to use > > Color.red.__class__.blue > > (what is being complained about in the issue), while not exactly pretty, > makes a lot more semantic sense than > > Color.red.blue > > ... which is just bizarre. > Any more bizarre than any other class that has properties of it's own type? a = 0 a.real.numerator.real.numerator It is only weird because we are not used to seeing classes where the properties are instances of the class. I am not a core developer, but I have been programming in Python for more than 10 years, and I (and the other similarly experienced developers I work with) found that not having access to the class level properties was weird (yes I am aware that they are not actually class level properties but everywhere else Enum works hard to make it look like they are. See for instance the __dir__ method: http://hg.python.org/cpython/file/ed011b0d7daf/Lib/enum.py#l242). -Chris -- Christopher Lambacher ch...@kateandchris.net
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com