Indented multi-line strings

Chris Angelico rosuav at gmail.com
Fri Jun 1 11:36:56 EDT 2018


On Sat, Jun 2, 2018 at 12:57 AM, Paul Moore <p.f.moore at gmail.com> wrote:
> On 1 June 2018 at 15:36, Dan Strohl via Python-list
> <python-list at python.org> wrote:
>> So... how does one go about suggesting changes to the built in types?  I could take a whack at the code for it, but my C skills are no where near what should probably be needed for something this close to the core of the language.  I'm not sure if adding a couple of methods is a PEP type of thing.
>
> It would probably have to go via python-ideas, but if it gets the OK
> there I doubt it would need a PEP.

Yeah, take it to -ideas but don't worry about a PEP.

> There are a few key questions I'd expect to see come up.
>
> Why does this need to be a string method? Why can't it be a standalone
> function? Maybe you should publish an implementation on PyPI, collect
> some data on how popular it is, and then if it's widely used, propose
> it for inclusion in the stdlib at that point? By making it a string
> method, you're also restricting its use to users of recent versions of
> Python, whereas a PyPI implementation would work for everyone.

The biggest reason to make it a string method is to give the
possibility of optimization. Python cannot optimize int(1.2) down to
the constant 1 because you might have shadowed int; but a method on a
string literal cannot be shadowed, and could potentially be
constant-folded. Include that in the initial post to preempt this
recommendation.

ChrisA



More information about the Python-list mailing list