On 04/29/2013 10:35 AM, Steven D'Aprano wrote:
On 30/04/13 02:42, Guido van Rossum wrote:
On Mon, Apr 29, 2013 at 6:51 AM, Eli Bendersky <eli...@gmail.com> wrote:
I don't feel strongly about allowing ()-lookup in addition to
[]-lookup, but
in this paragraph the issue of multiple definitions has sneaked in :-)
flufl.enum disallows this:
class Color(Enum):
red = 1
blue = 2
green = 1 # oops!
Has it been decided that this is now allowed?
I don't recall if it was decided. I think it should be possible to
create aliases like this. The main thing I care about is that
Color.green == Color.red.
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:
class Color(Enum):
red = 1
blue = 2
Color.green = Color.red
which satisfies me.
Assuming that Color(1) always returns the same object, then we could
also write this:
class Color(Enum):
red = 1
blue = 2
Color.green = Color(1)
Which should be identical to
class Color(Enum):
red = 1
blue = 2
green = 1
To declare that my first example is okay but the second is not strikes
me as awfully special. And I do mean awful.
//arry/
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com