Serhiy Storchaka added the comment:
The name IntFlags is inspired by the Flags attribute in C# (this is the most
close concept). The "Int" prefix is added for parallel with IntEnum and because
the class behaves as int in some contexts (supports operators |, &, ^, ~ and
can be passed to functions that require int). I don't know whether there is a
need in Flags class that is not a subclass of int.
Other languages provide something like EnumSet - a specialized set of enums.
But it has different interface.
1) If there are enum members FOO and BAR, their union is {FOO, BAR}, not
FOO|BAR.
2) The union member itself is not a set.
3) A set can contain only predefined set of values (IntFlag allows non-defined
bits be set).
If you thing that non-int flags could be useful, you can consider adding
EnumSet for general enums and IntFlags (or just Flags) for int-like enums. But
I think that new API can just use a set or a tuple of enums. IntFlags is needed
for compatibility with old API or C API.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue23591>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com