Showing content from http://mail.python.org/pipermail/python-dev/attachments/20130429/73e945c4/attachment.html below:
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix"><br>
On 04/29/2013 06:51 AM, Eli Bendersky wrote:<br>
</div>
<blockquote
cite="mid:CAF-Rda_HxrKD61aRRjruo0zBjNnJHc7BOuC1ZFN=fmaHKPtLtw@mail.gmail.com"
type="cite">
<div dir="ltr">flufl.enum disallows this:<br>
<div class="gmail_extra">
<br>
class Color(Enum):<br>
</div>
<div class="gmail_extra"> red = 1<br>
</div>
<div class="gmail_extra"> blue = 2<br>
</div>
<div class="gmail_extra"> green = 1 # oops!<br>
<br>
</div>
<div class="gmail_extra">Has it been decided that this is now
allowed? If this is indeed the case, then Color(1) is a
problem. The options are:<br>
<br>
</div>
<div class="gmail_extra">A. Return either Color.red or
Color.green<br>
</div>
<div class="gmail_extra">B. Throwing an error<br>
<br>
</div>
<div class="gmail_extra">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.<br>
<br>
Eli [trying to tie loose ends for updating the PEP].<br>
</div>
</div>
</blockquote>
<br>
Would you disallow this too?<br>
<blockquote>class Color(Enum):<br>
red = 1<br>
blue = 2<br>
Color.green = Color.red<br>
</blockquote>
<br>
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.<br>
<br>
See also "consenting adults",<br>
<br>
<br>
<i>/arry</i><br>
</body>
</html>
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