22.09.20 16:57, Ethan Furman пише:
> On 9/22/20 12:11 AM, Serhiy Storchaka wrote:
>> The only exception is StrEnum -- overriding __str__ of str
>> subclass may be not safe. Some code will call str() implicitly, other
>> will read the string content of the object directly, and they will be
>> differ
On 9/22/20 12:11 AM, Serhiy Storchaka wrote:
The only exception is StrEnum -- overriding __str__ of str
subclass may be not safe. Some code will call str() implicitly, other
will read the string content of the object directly, and they will be
different.
Following up on that:
>>> import e
19.09.20 00:44, Ethan Furman пише:
> I'm looking for arguments relating to:
>
> - should _convert_ make the default __repr__ be module_name.member_name?
In most cases enums with _convert_ are used to replace old module
globals. They are accessible as module_name.member_name and always used
as mod
On Fri, Sep 18, 2020 at 10:42 PM Guido van Rossum wrote:
> At the same time it's as old as Python -- for most builtins other than
> strings, repr() and str() are the same, and modeled after repr().
> Historically, I only introduced the difference between str() and repr()
> because of strings --
On 9/19/20 2:08 PM, Guido van Rossum wrote:
I'm just trying to present an argument that if the str() of an enum was
its name and the repr() was its "full name" (at least including the
class) that would be pretty sweet.
Well, we're still early enough in the 3.10 cycle we can make that change
That would be more palatable if it wasn't so common to use manually
assigned numerical values (as most of the examples in the enum module docs
do) or the default auto().
I'm just trying to present an argument that if the str() of an enum was its
name and the repr() was its "full name" (at least in
On Sat, Sep 19, 2020 at 11:44 AM Guido van Rossum wrote:
> Another brainstorm (or brainfart): maybe repr() should show the module/class
> and the name, and str() should only show the name. We'd then get
> ```
> >>> # Mock-up!
> >>> print(str(re.i))
> IGNORE
> >>> print(repr(re.i))
> re.IGNORE
> >
On 9/19/20 11:32 AM, Guido van Rossum wrote:
> On Sat, Sep 19, 2020 at 1:29 AM Ethan Furman wrote:
>> On 9/18/20 6:41 PM, Guido van Rossum wrote:
>>> Another brainstorm (or brainfart): maybe repr() should show the
>>> module/class and the name, and str() should only show the name. We'd
>>> then g
On Sat, Sep 19, 2020 at 1:29 AM Ethan Furman wrote:
> On 9/18/20 6:41 PM, Guido van Rossum wrote:
> [...]
> > Another brainstorm (or brainfart): maybe repr() should show the
> > module/class and the name, and str() should only show the name. We'd
> > then get
> > ```
> > >>> # Mock-up!
> >
On Fri, 18 Sep 2020 18:14:35 -0700
Ethan Furman wrote:
>
> So at this point, I think the choices are:
>
> Standard Enum
>__repr__ __str__
>RegexFlag.IGNORECASE
>
> and
>
> Modified Converted Constant
>__repr__ __str__
> re.IGNORECASE
Ethan Furman writes:
> I counted roughly 25 Enums in the stdlib at this point, and only two of
> them have modified reprs or strs; and one of those is an internal class.
> It's worth noting that two others are buggy -- one is being fancy with
> values and didn't get the custom __new__ cor
On 9/18/20 6:41 PM, Guido van Rossum wrote:
> On Fri, Sep 18, 2020 at 6:19 PM Ethan Furman wrote:
>> So at this point, I think the choices are:
>>
>> Standard Enum
>> __repr__ __str__
>>RegexFlag.IGNORECASE
>>
>> and
>>
>> Modified Converted Constant
>> _
On Fri, Sep 18, 2020 at 6:19 PM Ethan Furman wrote:
> On 9/18/20 3:12 PM, Guido van Rossum wrote:
> > On 9/18/20 2:44 PM, Ethan Furman wrote:
>
> >> I'm looking for arguments relating to:
> >>
> >> - should _convert_ make the default __repr__ be
> >> module_name.member_name?
> >
> > I ac
On 9/18/20 3:12 PM, Guido van Rossum wrote:
> On 9/18/20 2:44 PM, Ethan Furman wrote:
>> I'm looking for arguments relating to:
>>
>> - should _convert_ make the default __repr__ be
>> module_name.member_name?
>
> I actually like the status quo for regular enums, when repr() shows
> the type, n
Okay, let me take a shot at this.
I actually like the status quo for regular enums, when repr() shows the
type, name and value, and str() shows "classname.flagname", so I'd stick to
that for converted flags. Even though this violates the rule of thumb that
repr() should look like a valid expressio
15 matches
Mail list logo