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

BartC bc at freeuk.com
Sun Apr 24 13:54:57 EDT 2016


On 24/04/2016 17:47, Chris Angelico wrote:
> 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,

And, perhaps, to be actual enumerations. (So that in the set (a,b,c,d), 
you don't know nor care about the underlying values, except that they 
are distinct.)

-- 
Bartc



More information about the Python-list mailing list