Message191601
| Author |
ethan.furman |
| Recipients |
amaury.forgeotdarc, barry, eli.bendersky, eric.snow, ethan.furman, ezio.melotti, gvanrossum, ncoghlan, pitrou, rhettinger |
| Date |
2013年06月21日.17:35:59 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1371836159.69.0.175455919906.issue18264@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
I'd be in favor of the __protocol__ route first and the PEP 443 route second.
The problem with just tacking in `str(int(value))` or `str(float(value))` is where does it stop? StrEnum, TupleEnum, BytesEnum, ComplexEnum, SomeOtherInterestingConstantEnum, etc., etc..
If we go the __protocol__ route we add one method to Enum which returns the `str` of its `.value`, and we're set for every Enum.* As a bonus, any other object that needs special json (or yaml or whatever) consideration has a fairly easy way to make it happen.
*Every normal Enum, anyway. ;) |
|