[Python-Dev] constant/enum type in stdlib
Raymond Hettinger
raymond.hettinger at gmail.com
Sun Nov 28 00:26:13 CET 2010
On Nov 27, 2010, at 12:56 PM, Glenn Linderman wrote:
> On 11/27/2010 2:51 AM, Nick Coghlan wrote:
>>
>> Not quite. I'm suggesting a factory function that works for any value,
>> and derives the parent class from the type of the supplied value.
>
> Nick, thanks for the much better implementation than I achieved; you seem to have the same goals as my implementation. I learned a bit making mine, and more understanding yours to some degree. What I still don't understand about your implementation, is that when adding one additional line to your file, it fails:
>
> w = named_value("ABC", z )
>
> Now I can understand why it might not be a good thing to make a named value of a named value (confusing, at least), but I was surprised, and still do not understand, that it failed reporting the __new__() takes exactly 3 arguments (2 given).
Can I suggest that an enum-maker be offered as a third-party module rather than prematurely adding it into the standard library.
Raymond
More information about the Python-Dev
mailing list