[Python-ideas] Deprecating rarely used str methods

Chris Angelico rosuav at gmail.com
Sun Aug 11 23:42:35 CEST 2013


On Sun, Aug 11, 2013 at 10:14 PM,  <random832 at fastmail.us> wrote:
>
>
> On Fri, Aug 9, 2013, at 23:58, Chris Angelico wrote:
>> Oh, I can see the other side's arguments. If str.format existed and
>> str% didn't, there would be insufficient grounds to add it. But they
>> both exist, and the arguments for removing a feature have to be
>> insanely strong. Status quo wins easily.
>
> What exactly was the sufficient grounds for adding str.format, and for
> giving it its own minilanguage instead of using the one % already uses
> [with extensions like being able to use both positional arguments and
> %(keyword)s, and maybe something like %1$s for explicit positional
> arguments]?

Or %[3]s for the 3rd argument (zero-based, so "%s%[0]s" would
duplicate the string). And %{...%} to repeat the inner content for
every element of the argument iterable. There's a lot that can be done
to extend sprintf notation, if someone wants to. But I don't know that
Python wants to do that, unless str.format is to be obsoleted.

Here's a few ideas that could be borrowed, if desired:

http://pike.lysator.liu.se/generated/manual/modref/ex/predef_3A_3A/sprintf.html

ChrisA


More information about the Python-ideas mailing list