[issue32218] add __iter__ to enum.Flag members

2021-01-13 Thread Ethan Furman


Ethan Furman  added the comment:

Final outcome:

`Flag` has been redesigned such that any flag comprised of a single bit is 
canonical; flags comprised of multiple bits are considered aliases.  During 
iteration only canonical flags are returned.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32218] add __iter__ to enum.Flag members

2020-11-18 Thread Henk-Jaap Wagenaar


Henk-Jaap Wagenaar  added the comment:

What does aenum do and has there been any feedback on it?

To me I would see what you suggest as surprising but I don't use enums often (I 
should use them more!) so take that with a grain of salt, and also surprising 
!= wrong/not good.

--
nosy: +cryvate

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32218] add __iter__ to enum.Flag members

2020-11-18 Thread hongweipeng


Change by hongweipeng :


--
nosy: +hongweipeng
nosy_count: 5.0 -> 6.0
pull_requests: +22261
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/23368

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32218] add __iter__ to enum.Flag members

2020-09-19 Thread Ethan Furman


Ethan Furman  added the comment:

Problem:  What to do when the Flag has compound members?

class Color(Flag):
BLACK = 0
RED = 1
GREEN = 2
BLUE = 4
PURPLE = RED|BLUE
WHITE = RED|GREEN|BLUE

I think the answer is: only return the single members.  So

  --> list(Color.WHITE)
  [Color.BLUE, Color.GREEN, Color.RED]

--
resolution: fixed -> 
stage: resolved -> needs patch
status: closed -> open

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32218] add __iter__ to enum.Flag members

2020-09-17 Thread Ethan Furman


Change by Ethan Furman :


--
components: +Library (Lib)
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.10 -Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32218] add __iter__ to enum.Flag members

2020-09-12 Thread Ethan Furman


Change by Ethan Furman :


--
keywords: +patch
pull_requests: +21276
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/1

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32218] add __iter__ to enum.Flag members

2018-01-29 Thread Ethan Furman

Ethan Furman  added the comment:

This functionality is now in the third-party aenum* library.

Are there any strong use-cases for this behavior such that it should be in the 
stdlib?


* as of version 2.0.10, available on PyPI, and I am its author

--
nosy: +barry, eli.bendersky, rhettinger
stage: needs patch -> 
versions: +Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32218] add __iter__ to enum.Flag members

2018-01-18 Thread Ethan Furman

Change by Ethan Furman :


--
assignee:  -> ethan.furman
stage:  -> needs patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32218] add __iter__ to enum.Flag members

2017-12-04 Thread Berker Peksag

Change by Berker Peksag :


--
nosy: +ethan.furman

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32218] add __iter__ to enum.Flag members

2017-12-04 Thread Guy Gangemi

New submission from Guy Gangemi :

I'm proposing to extend enum.Flag member functionality so it is iterable in a 
manner similar to enum.Flag subclasses.

from enum import Flag, auto


class FlagIter(Flag):
def __iter__(self):
for memeber in self._member_map_.values():
if member in self:
yield member


class Colour(FlagIter):
RED = auto()
GREEN = auto()
BLUE = auto()
YELLOW = RED | GREEN

cyan = Colour.GREEN | Colour.Blue

print(*Colour)  # Colour.RED Colour.GREEN Colour.BLUE Colour.YELLOW

# Without the enhancement, 'not iterable' is thrown for these
print(*cyan)  # Colour.GREEN Colour.BLUE
print(*Colour.YELLOW)  # Colour.RED Colour.GREEN Colour.YELLOW
print(*~Colour.RED)  # Colour.GREEN Colour.BLUE

--
messages: 307629
nosy: Guy Gangemi
priority: normal
severity: normal
status: open
title: add __iter__ to enum.Flag members
type: enhancement

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com