Re: Enum with only a single member

2017-01-10 Thread Peter Otten
Steven D'Aprano wrote: > Is it silly to create an enumeration with only a single member? That is, a > singleton enum? > > from enum import Enum > > class Unique(Enum): > FOO = auto() > > > The reason I ask is that I have two functions that take an enum argument. > The first takes one of

Re: Enum with only a single member

2017-01-10 Thread jmp
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:

Re: Enum with only a single member

2017-01-10 Thread Ethan Furman
On 01/10/2017 12:37 AM, Chris Angelico wrote: On Tue, Jan 10, 2017 at 7:33 PM, Paul Rubin wrote: That is, a singleton enum? Why stop there? You can make empty ones too. (Zerotons?) Sure you *can*, but I can't think of any time they'd be useful. Can you give an example? Sure. Any time

Re: Enum with only a single member

2017-01-10 Thread Chris Angelico
On Tue, Jan 10, 2017 at 7:33 PM, Paul Rubin wrote: >> That is, a singleton enum? > > Why stop there? You can make empty ones too. (Zerotons?) Sure you *can*, but I can't think of any time they'd be useful. Can you give an example? ChrisA --

Re: Enum with only a single member

2017-01-10 Thread Paul Rubin
Steven D'Aprano writes: > Is it silly to create an enumeration with only a single member? No. > 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 >

Re: Enum with only a single member

2017-01-09 Thread Jussi Piitulainen
Steven D'Aprano writes: > Is it silly to create an enumeration with only a single member? That > is, a singleton enum? > > from enum import Enum > > class Unique(Enum): > FOO = auto() > > > The reason I ask is that I have two functions that take an enum > argument. The first takes one of

Re: Enum with only a single member

2017-01-09 Thread Ethan Furman
On 01/09/2017 08:43 PM, Steven D'Aprano wrote: Is it silly to create an enumeration with only a single member? That is, a singleton enum? from enum import Enum class Unique(Enum): FOO = auto() The reason I ask is that I have two functions that take an enum argument. The first takes one

Enum with only a single member

2017-01-09 Thread Steven D'Aprano
Is it silly to create an enumeration with only a single member? That is, a singleton enum? from enum import Enum class Unique(Enum): FOO = auto() The reason I ask is that I have two functions that take an enum argument. The first takes one of three enums: class MarxBros(Enum):