Comparing Python enums to Java, was: How much sanity checking is required for function inputs?

Chris Angelico rosuav at gmail.com
Sun Apr 24 12:47:36 EDT 2016


On Mon, Apr 25, 2016 at 2:42 AM, Ethan Furman <ethan at stoneleaf.us> wrote:
>> Easy: allow an empty list to have the same meaning as an empty tuple.
>> Every time you have [] in your source code, you're guaranteed to get a
>> new (unique) empty list, and then multiple assignment will work.
>
>
> *sigh*
>
> Where were you three years ago?  ;)
>
> Actually, thinking about it a bit more, if we did that then one could not
> use an empty list as an enum value.  Why would one want to?  No idea, but to
> make it nearly impossible I'd want a much better reason than a minor
> inconvenience:

I would normally expect enumerated values to be immutable and
hashable, but that isn't actually required by the code AIUI. Under
what circumstances is it useful to have mutable enum values?

ChrisA



More information about the Python-list mailing list