[Python-ideas] Re: Allowing `str.format` to format one or more parameters instead of all parameters

2023-04-21 Thread Matthias Görgens
What's the use-case for this? Have you looked into using functools.partial instead? On Sat, 22 Apr 2023, 06:23 Samuel Muldoon, wrote: > Consider the following string: > > x = r"\mathjax{{color}}{{text}}" > > string `x` contains two parameters named `color` and the other named `text > `. > > Cur

[Python-ideas] Re: Allowing `str.format` to format one or more parameters instead of all parameters

2023-04-21 Thread Greg Ewing
On 22/04/23 10:20 am, Samuel Muldoon wrote: Can we change str.formatso that it is possible to change only one string parameter, but leave the other parameters alone? That would have the effect that every use of str.format for everyone would start producing partially-formatted strings if an argu

[Python-ideas] Allowing `str.format` to format one or more parameters instead of all parameters

2023-04-21 Thread Samuel Muldoon
Consider the following string: x = r"\mathjax{{color}}{{text}}" string `x` contains two parameters named `color` and the other named `text`. Currently, python requires that the string class method `str.format` contain key-word arguments for *all *parameters, not just *one* parameter result = r"

[Python-ideas] Re: Protocols Subclassing Normal Classes

2023-04-21 Thread Chris Angelico
On Fri, 21 Apr 2023 at 22:57, Jordan Macdonald wrote: > However, I then encountered an issue: I could define a Protocol that > specified the 'stop()' method easily enough, but if I annotated the manager > as taking that, it would accept any class which implemented a method named > 'stop()', whi

[Python-ideas] Protocols Subclassing Normal Classes

2023-04-21 Thread Jordan Macdonald
We have a large codebase which uses threads. Many - but not all - of these threads implement a method named 'stop()' which sets a flag, triggers an event, closes a connection, or what-have-you in order to command the thread in question to terminate. I was writing a thread manager, intended to auto