[issue29594] implementation of __or__ in enum.auto

2017-03-01 Thread Ethan Furman
Ethan Furman added the comment: Serhiy, agreed. Closing. Marc, thanks, I see I missed supporting non-auto() combinations. Feel free to open an issue for that at: https://bitbucket.org/stoneleaf/aenum Either way I'll get that fixed. -- resolution: -> rejected stage: -> resolved

[issue29594] implementation of __or__ in enum.auto

2017-03-01 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I don't think it is worthwhile. Using underscored names looks pretty pythonic to me. -- ___ Python tracker ___

[issue29594] implementation of __or__ in enum.auto

2017-03-01 Thread Marc Guetg
Marc Guetg added the comment: @ethan, didn't know about aenum, thanks for showing it to me. However it doesn't seem to support the behavior I'm after (or I'm doing something wrong) import aenum try: class Foo(aenum.Flag): a = aenum.auto() b = a |

[issue29594] implementation of __or__ in enum.auto

2017-03-01 Thread Ethan Furman
Ethan Furman added the comment: aenum 2.0 [1] has been released. Because it also covers Python 2.7 I had to enhance its auto() to cover |, &, ^, and ~ so that Enum classes could be properly created. At this moment your choices are to use odd naming or aenum (with its enhanced auto). [1]

[issue29594] implementation of __or__ in enum.auto

2017-02-22 Thread Ethan Furman
Ethan Furman added the comment: I also think using leading underscores is a better way to signal that a particular value is "weird". -- ___ Python tracker

[issue29594] implementation of __or__ in enum.auto

2017-02-22 Thread Ethan Furman
Ethan Furman added the comment: @Julian: Giving flag combinations their own name can be useful. For example, instead of seeing Color.GREEN|RED one can see Color.YELLOW . @Marc: I'm not convinced this is a needed change as it doesn't seem to be a common method, nor one that cannot be easily

[issue29594] implementation of __or__ in enum.auto

2017-02-19 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Just make C and D protected or private. class Foo(Flag): A = auto() B = auto() AB = A | B _C = auto() __D = auto() AC = A | _C ABD = A | B | __D -- nosy: +serhiy.storchaka ___ Python

[issue29594] implementation of __or__ in enum.auto

2017-02-19 Thread Marc Guetg
Marc Guetg added the comment: One made-up use-case would be: class LogLevel(Flags): start = auto() log1 = start | auto() log2 = start | auto() def fun(flags, *args): if start in flags: # open log file if log1 in flags: # Log important thing 1 if log2

[issue29594] implementation of __or__ in enum.auto

2017-02-19 Thread Julien Palard
Julien Palard added the comment: Your implementation looks right, but I don't see the point of defining combinations AB, AC, ABD in the Foo enum. Foo may only define A, B, C, D and outside of Foo anyone can build any needed combinations. This way it looks clear in the Foo declaration (4

[issue29594] implementation of __or__ in enum.auto

2017-02-19 Thread Berker Peksag
Changes by Berker Peksag : -- nosy: +ethan.furman ___ Python tracker ___ ___

[issue29594] implementation of __or__ in enum.auto

2017-02-17 Thread Marc Guetg
Changes by Marc Guetg : -- title: implement __or__ in enum.auto -> implementation of __or__ in enum.auto ___ Python tracker ___