On 25Apr2021 01:01, Chris Angelico wrote:
>On Sat, Apr 24, 2021 at 11:36 PM Stephen J. Turnbull
> wrote:
>> Assuming that *exact* use case, wouldn't
>>
>> >>> class LowerableStr(str):
>> ... def __format__(self, fmt):
>> ... if fmt == 'lc':
>> ...return self.lower()
>> .
On 24Apr2021 22:35, Stephen J. Turnbull
wrote:
>Cameron Simpson writes:
> > On 23Apr2021 18:25, Stephen J. Turnbull
> > wrote:
> > >I don't understand how this is supposed to work. It looks to me
> > >like !code is a preprocessor: [...]
> > >If so,
> > >
> > >'{x} is {x!lc:foo} in lowerca
On Sat, Apr 24, 2021 at 11:36 PM Stephen J. Turnbull
wrote:
> Assuming that *exact* use case, wouldn't
>
> >>> class LowerableStr(str):
> ... def __format__(self, fmt):
> ... if fmt == 'lc':
> ...return self.lower()
> ... else:
> ...return str.__format__(self,
Cameron Simpson writes:
> On 23Apr2021 18:25, Stephen J. Turnbull
> wrote:
> >I don't understand how this is supposed to work. It looks to me like
> >!code is a preprocessor: [...]
> >If so,
> >
> >'{x} is {x!lc:foo} in lowercase'
> >
> >will fail because str doesn't implement the
21.04.21 12:14, Paul Moore пише:
> I don't have a particularly strong opinion here, other than to say I'm
> not sure I like the upper case "I". It looks far too much like a lower
> case "L" in the font I'm using here, which makes me think of C's
> "long", so it's easy to confuse. So of the two opti
23.04.21 12:22, Stephen J. Turnbull пише:
> Serhiy Storchaka writes:
>
> > Currently format strings (and f-string expressions) support three
> > conversions: !s -- str, !r -- repr and !a for ascii.
>
> It's not clear to me what these are good for, to be honest. Why not
> just have s, r, and a