Enum with only a single member

jmp jeanmichel at sequans.com
Tue Jan 10 04:47:01 EST 2017


On 01/10/2017 05:43 AM, Steven D'Aprano wrote:
> Is it silly to create an enumeration with only a single member? That is, a
> singleton enum?

Don't think so, for the same reason that lists with one element make sense.

> def ham(arg):
>      if isinstance(arg, MarxBros) or arg is Unique.FOO:
>          ...
>
>
> Good, bad or indifferent?
>


Though I'd write

def ham(arg):
   if arg in MarxBros or arg in Unique:
     ...


JM



More information about the Python-list mailing list