On Mon, Sep 23, 2013 at 09:45:46AM -0400, Chris Lambacher wrote:
[...] 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.

I'm having a hard time seeing why the latter is problematic, I must
admit (certainly no more so than the "Alice in Wonderland" side effects
previously described).

[...] An example of how this will be used in practice is:

{% if object.state == object.state.completed %}
some html
{% endif %}

The names used slightly obscure the weirdness of it, but what you're
really saying there is:

     if my_state == my_state.another_state

... which feels more like a code smell to me than

      {% if object.state == State.completed %}
        some html
      {% endif %}

That's quite intelligible, and doesn't require anyone to know that an
Enum member's siblings can, in your proposal, be accessed directly via
dot notation (an unintuitive state of affairs, to me at least).


Zero Piraeus: omnia omnibus

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 9 of 16 | next ›
Discussion Overview
grouppython-dev @
postedSep 22, '13 at 11:52p
activeSep 23, '13 at 11:25p



site design / logo © 2022 Grokbase