[Python-ideas] PEP XXX - Competitor with PEP 435: Adding an enum type to the Python standard library

Ethan Furman ethan at stoneleaf.us
Wed Mar 13 02:55:40 CET 2013

On 03/12/2013 06:03 PM, Random832 wrote:
> On 03/12/2013 06:17 PM, Alex Stewart wrote:
>> effectively multi-enum sets
> Speaking of sets... it seems like sets of single enum values would be a good way to represent "ORed-together enums". But
> then if you want a function to accept one, it has to be able to not care if it's only a single one or not.
> So, what if each value of a 'flags' type enum is also able to be treated as a single-member set of itself?

In aenum.py you are able to iterate over a BitMask enum, both single ones and ORed together ones, even if it only has 
one value.  The code looks like this:


     def __iter__(yo):
         enums = []
         for enum in yo._enums:
             if int(enum) & int(yo):
         return iter(enums)



More information about the Python-ideas mailing list