(original) (raw)
On 9/18/2017 11:37 AM, Ethan Furman
wrote:
On 09/11/2017 03:28 PM, Guido van Rossum wrote:snip
Oddly I don't like the enum (flag names get too long that way), but I do agree with everything else Barry said (it
should be a trivalue flag and please don't name it cmp).
Hmmm, named constants are one of the motivating factors for having an Enum type. It's easy to keep the name a reasonable length, however: export them into the module-level namespace. re is an excellent example; the existing flags were moved into a FlagEnum, and then (for backwards compatibility) aliased back to the module level:
Likewise, if we had:
class Compare(enum.Enum):
NONE = 'each instance is an island'
EQUAL = 'instances can be equal to each other'
ORDERED = 'instances can be ordered and/or equal'
globals().update(Compare.\_\_members\_\_)
then we can still use, for example, EQUAL, but get the more informative repr and str when we need to.
I tend to like the Enum also. But maybe this is a case where there should be multiple different decorators:
@dataclass
@equality\_dataclass
@ordered\_datatclass