<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 10:35 AM, Steven D'Aprano wrote:<br>
</div>
<blockquote cite="mid:517EAF5A.8000606@pearwood.info" type="cite">On
30/04/13 02:42, Guido van Rossum wrote:
<br>
<blockquote type="cite">On Mon, Apr 29, 2013 at 6:51 AM, Eli
Bendersky <a class="moz-txt-link-rfc2396E" href="mailto:eliben@gmail.com"><eliben@gmail.com></a> wrote:
<br>
<blockquote type="cite">I don't feel strongly about allowing
()-lookup in addition to []-lookup, but
<br>
in this paragraph the issue of multiple definitions has
sneaked in :-)
<br>
flufl.enum disallows this:
<br>
<br>
class Color(Enum):
<br>
red = 1
<br>
blue = 2
<br>
green = 1 # oops!
<br>
<br>
Has it been decided that this is now allowed?
<br>
</blockquote>
<br>
I don't recall if it was decided. I think it should be possible
to
<br>
create aliases like this. The main thing I care about is that
<br>
Color.green == Color.red.
<br>
</blockquote>
<br>
I believe that Barry had decided that it should be prohibited. I
objected, and Nick pointed out that although declaring two enums
with the same value inside the class is prohibited, aliases are
supported by adding them from the outside:
<br>
<br>
class Color(Enum):
<br>
red = 1
<br>
blue = 2
<br>
<br>
Color.green = Color.red
<br>
<br>
which satisfies me.<br>
</blockquote>
<br>
Assuming that Color(1) always returns the same object, then we could
also write this:<br>
<blockquote>class Color(Enum):<br>
red = 1<br>
blue = 2<br>
Color.green = Color(1)<br>
</blockquote>
<br>
Which should be identical to<br>
<blockquote>class Color(Enum):<br>
red = 1<br>
blue = 2<br>
green = 1<br>
</blockquote>
To declare that my first example is okay but the second is not
strikes me as awfully special. And I do mean awful.<br>
<br>
<br>
<i>/arry</i><br>
</body>
</html>