On Thu, Apr 29, 2021 at 2:00 PM Ethan Furman <ethan@stoneleaf.us> wrote:
On 4/29/21 10:35 AM, Jonathan Goble wrote:
 > On Thu, Apr 29, 2021 at 1:20 PM Ethan Furman wrote:


 >> Which raises the question:  Do we want to have a standard name for stdlib Flags when no flags are set?
 >
 > If you want a flag to represent no flags set, it takes one line to write it yourself, as in this example I copied
 > verbatim from the docs:
 >
 >  >>> class Color(Flag):
 > ...     BLACK = 0
 > ...     RED = auto()
 > ...     BLUE = auto()
 > ...     GREEN = auto()
 > ...
 >  >>> Color.BLACK
 > <Color.BLACK: 0>
 >  >>> bool(Color.BLACK)
 > False

Are you suggesting that the standard name for 0 be 'BLACK'?  ;-)

Any color you want as long as it's BLACK. ;-)

But seriously, my point is that it's already trivially possible for enum authors to give the zero case a name of their own choosing that makes sense for their use case, so we don't need special automatic names for it. The one obvious way to do it, and the explicit way to do it, is to define your own name to be equal to zero. Creating an automatic name for zero now, after the enum module is well-established, violates the Zen of Python in at least three, possibly four ways:

- it's implicit behavior (compared to the explicitness of defining your own name)
- it violates the "one obvious way to do it" principle (I can conceivably see arguments developing in the community over whether the automatic name should be preferred or if one should write an explicit name for zero, as neither is clearly and obviously better than the other)
- it requires a special case for backward compatibility with the @enum.unique decorator
- it's arguably ambiguous what object should be returned for foo(0) when an explicit name is defined (due to the documented behavior that a second name for the same value is an alias for the first; is the automatic name created first or last?)

So I don't see any compelling argument for giving an automatic name for zero. Just define your own name. It takes five seconds and one line, with essentially zero cost to maintainability.