Ian Kelly :
> On Fri, May 25, 2018 at 11:00 PM, Chris Angelico wrote:
>> On Sat, May 26, 2018 at 2:46 PM, Steven D'Aprano
>>> class State(Enum):
>>> Maybe = 2
>>
>> # Tri-state logic
>> Maybe = object()
>
> The enum has a nice __str__ though.
That's why I usually use string sentinels:
May
On 05/26/2018 01:00 AM, Steven D'Aprano wrote:
I wish there was a simpler way to define symbols with identity but no
state or behaviour...
Check out the Constant class in aenum. You still might want to customize the
repr, though.
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/pytho
On Sat, 26 May 2018 23:54:51 +1000, Chris Angelico wrote:
> Seems pretty non-controversial, which means it's almost guaranteed to
> reach 100+ posts debating what the name should be.
Including:
* 27 posts declaring that using such singleton symbols is completely
un-Pythonic and is sure to doom
On Sat, May 26, 2018 at 6:50 PM, Steven D'Aprano
wrote:
> On Sat, 26 May 2018 18:14:08 +1000, Chris Angelico wrote:
>
>> On Sat, May 26, 2018 at 6:00 PM, Steven D'Aprano
>> wrote:
>>> Actually I don't really need all the features of Enums, I might just
>>> define my own class:
>>>
>>>
>>> class M
Steven D'Aprano wrote:
> Am I silly for wanting to make a single enum?
>
> I have a three-state flag, True, False or Maybe. Is is confusing or bad
> practice to make a single enum for the Maybe case?
>
>
> from enum import Enum
> class State(Enum):
> Maybe = 2
>
> Maybe = State.Maybe
> del
Ian Kelly :
> On Fri, May 25, 2018 at 11:00 PM, Chris Angelico wrote:
>> # Tri-state logic
>> Maybe = object()
>
> The enum has a nice __str__ though.
I use strings for enums:
class X:
HERE = "HERE"
THERE = "THERE"
EVERYWHERE = "EVERYWHERE"
def __init__(self):
26.05.18 08:07, Ian Kelly пише:
On Fri, May 25, 2018 at 11:00 PM, Chris Angelico wrote:
On Sat, May 26, 2018 at 2:46 PM, Steven D'Aprano
wrote:
Am I silly for wanting to make a single enum?
I have a three-state flag, True, False or Maybe. Is is confusing or bad
practice to make a single enum
On Sat, 26 May 2018 18:14:08 +1000, Chris Angelico wrote:
> On Sat, May 26, 2018 at 6:00 PM, Steven D'Aprano
> wrote:
>> Actually I don't really need all the features of Enums, I might just
>> define my own class:
>>
>>
>> class Maybe:
>> def __repr__(self):
>> return "Maybe"
>>
>>
On Sat, May 26, 2018 at 6:00 PM, Steven D'Aprano
wrote:
> Actually I don't really need all the features of Enums, I might just
> define my own class:
>
>
> class Maybe:
> def __repr__(self):
> return "Maybe"
>
> Maybe = Maybe()
>
>
>
> I wish there was a simpler way to define symbols
On Fri, 25 May 2018 23:07:47 -0600, Ian Kelly wrote:
> On Fri, May 25, 2018 at 11:00 PM, Chris Angelico
> wrote:
>> On Sat, May 26, 2018 at 2:46 PM, Steven D'Aprano
>> wrote:
[...]
>>> Is there a better way of handling a three-state flag like this?
>>>
>>>
>> Does it need to have a value of 2? I
On Sat, May 26, 2018 at 3:07 PM, Ian Kelly wrote:
> On Fri, May 25, 2018 at 11:00 PM, Chris Angelico wrote:
>> On Sat, May 26, 2018 at 2:46 PM, Steven D'Aprano
>> wrote:
>>> Am I silly for wanting to make a single enum?
>>>
>>> I have a three-state flag, True, False or Maybe. Is is confusing or
On Fri, May 25, 2018 at 11:00 PM, Chris Angelico wrote:
> On Sat, May 26, 2018 at 2:46 PM, Steven D'Aprano
> wrote:
>> Am I silly for wanting to make a single enum?
>>
>> I have a three-state flag, True, False or Maybe. Is is confusing or bad
>> practice to make a single enum for the Maybe case?
On Sat, May 26, 2018 at 2:46 PM, Steven D'Aprano
wrote:
> Am I silly for wanting to make a single enum?
>
> I have a three-state flag, True, False or Maybe. Is is confusing or bad
> practice to make a single enum for the Maybe case?
>
>
> from enum import Enum
> class State(Enum):
> Maybe = 2
Am I silly for wanting to make a single enum?
I have a three-state flag, True, False or Maybe. Is is confusing or bad
practice to make a single enum for the Maybe case?
from enum import Enum
class State(Enum):
Maybe = 2
Maybe = State.Maybe
del State
Is there a better way of handling a
14 matches
Mail list logo