Enum with only a single member
no.email at nospam.invalid
Tue Jan 10 03:33:32 EST 2017
Steven D'Aprano <steve+comp.lang.python at pearwood.info> writes:
> Is it silly to create an enumeration with only a single member?
> That is, a singleton enum?
Why stop there? You can make empty ones too. (Zerotons?)
> The reason I ask is that I have two functions that take an enum
Sounds like a good reason.
> def spam(arg):
> if isinstance(arg, MarxBros):
> def ham(arg):
> if isinstance(arg, MarxBros) or arg is Unique.FOO:
> Good, bad or indifferent?
Ummmm, that's ugly, but the alternatives are worse unless there's more
branches, and maybe even then.
More information about the Python-list