[Python-ideas] a set of enum.Enum values rather than the construction of bit-sets as the "norm"?

Guido van Rossum guido at python.org
Wed Jan 3 10:41:02 EST 2018


On Wed, Jan 3, 2018 at 8:24 AM, Random832 <random832 at fastmail.com> wrote:

> On Sun, Dec 31, 2017, at 00:33, Guido van Rossum wrote:
> > I'm not keen on this recommendation. An argument that takes a Set[Foo]
> > would mean that in order to specify:
> > - no flags: you'd have to pass set() -- you can't use {} since that's an
> > empty dict, not an empty set
>
> Optional[Set[Foo]]?
>
> > - one flag: you'd have to pass {Foo.BAR} rather than just Foo.BAR
> > - two flags: you'd have to pass {Foo.BAR, Foo.BAZ} rather than Foo.BAR |
> > Foo.BAZ
>
> Maybe the flags themselves should be of a type that you can do both with
> (i.e. each value is a set containing itself).
>

That's pretty much what the enum.Flag type does.

-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180103/37d98302/attachment.html>


More information about the Python-ideas mailing list