← 输入框|bugs.python.org|刷新

➜

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

作者 barry
收信人 barry, ncoghlan
日期 2013-06-19.13:58:03
SpamBayes Score -1.0
Marked as misclassified 是
Message-id <20130619095759.7855f9bc@anarchist>
In-reply-to <1371649541.07.0.776235119954.issue18264@psf.upfronthosting.co.za>
内容
On Jun 19, 2013, at 01:45 PM, Nick Coghlan wrote:

>Allowing __str__ to be inherited from Enum rather than from the concrete type
>will similarly break any serialisation protocol that relies on str() to
>handle integers. The float case is even trickier, since failing to inherit
>__repr__ would rather miss the point of the whole exercise...

Serialization isn't the only issue - you have to know how to deserialize as
well.  I use JSON extensively in Mailman's REST API.  For enums I always
encode them to just the member name, because I always know what enum class
will be used to deserialize them.

(TBH, I wish the json module had better hooks for extending both serialization
and deserialization of non-basic types.)
历史
日期 用户 动作 参数
2013-06-19 13:58:04barry修改recipients: + barry, ncoghlan
2013-06-19 13:58:04barry链接issue18264 messages
2013-06-19 13:58:03barry创建