A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2013-April/125712.html below:

[Python-Dev] enum discussion: can someone please summarize open issues?

[Python-Dev] enum discussion: can someone please summarize open issues? [Python-Dev] enum discussion: can someone please summarize open issues?Larry Hastings larry at hastings.org
Mon Apr 29 18:30:35 CEST 2013
On 04/29/2013 06:51 AM, Eli Bendersky wrote:
> flufl.enum disallows this:
>
> class Color(Enum):
>   red = 1
>   blue = 2
>   green = 1 # oops!
>
> Has it been decided that this is now allowed? If this is indeed the 
> case, then Color(1) is a problem. The options are:
>
> A. Return either Color.red or Color.green
> B. Throwing an error
>
> Do we have a decision on this? Personally I think the latter is 
> better; the former is error prone and doesn't seem to be useful too often.
>
> Eli [trying to tie loose ends for updating the PEP].

Would you disallow this too?

    class Color(Enum):
       red = 1
       blue = 2
    Color.green = Color.red


IMO the more Pythonic behavior would be to allow multiple names for the 
same value, and your example should produce the same result as my 
example.  I'm not convinced enums are special enough to break the rules.

See also "consenting adults",


//arry/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20130429/73e945c4/attachment.html>
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4