original) (raw)
(On 5 May 2013 21:58, Tim Delaney <timothy.c.delaney@gmail.com> wrote:
On 5 May 2013 16:17, Ethan Furman <ethan@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\_\_().
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 definitionSubclasses 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\_\_.
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