[Python-ideas] Enum and serialization

Ethan Furman ethan at stoneleaf.us
Fri Jul 19 18:07:19 CEST 2013


On 07/18/2013 10:11 PM, Nick Coghlan wrote:
> On 19 July 2013 04:24, Ethan Furman <ethan at stoneleaf.us> wrote:
>>
>> For the 3.4 stdlib there are two proposals on the table:
>>
>>    1) for IntEnum and FloatEnum cast the member to int or float, then
>> procede;
>>
>>    2) for any Enum, extract the value and proceed.
>
> 3) Only change repr (not str) in IntEnum
>
> I know Guido doesn't like it, but I still think the backwards
> compatibility risk is too high to use them to replace constants in the
> standard library if they change the output of __str__. Debugging only
> needs repr, and we can make sure stdlib error messages use repr, too.

The issue with that solution is json uses repr, not str, for floats.  So we would still have a problem.

--
~Ethan~


More information about the Python-ideas mailing list