[Python-Dev] PEP 435 - reference implementation discussion

Tim Delaney timothy.c.delaney at gmail.com
Mon May 6 01:22:58 CEST 2013

On 5 May 2013 21:58, Tim Delaney <timothy.c.delaney at gmail.com> wrote:

> On 5 May 2013 16:17, Ethan Furman <ethan at stoneleaf.us> wrote:
>> On 05/04/2013 10:59 PM, Ethan Furman wrote:
>>> On 05/04/2013 08:50 PM, Tim Delaney wrote:
>>>> 2. Instead of directly setting the _name and _value of the enum_item,
>>>> it lets the Enum class do it via Enum.__init__().
>>> Subclasses can override this. This gives Enums a 2-phase construction
>>>> just like other classes.
>>> Not sure I care for this.  Enums are, at least in theory, immutable
>>> objects, and immutable objects don't call __init__.
>> Okay, still thinking about `value`, but as far as `name` goes, it should
>> not be passed -- it must be the same as it was in the class definition
> Agreed - name should not be passed.
> I would have preferred to use __new__, but Enum.__new__ doesn't get called
> at all from enum_type (and the implementation wouldn't be at all
> appropriate anyway).

*If* I can manage to convince Guido and Eli over in that other (initial
values) thread, I think it's still probably worthwhile calling __init__ on
the enum instance, but with no parameters. That would allow more
behaviour-based enums to set up any other initial state they require.

Tim Delaney
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20130506/9637eda3/attachment.html>

More information about the Python-Dev mailing list