[Python-ideas] Draft PEP on string interpolation

Mike Miller python-ideas at mgmiller.net
Tue Aug 25 04:36:47 CEST 2015


On 08/24/2015 07:05 PM, Nikolaus Rath wrote:
> How is that compatible with your statement that
>
>> This means a billion lines of code using e-strings won't have to care
>> about them, only a handful of places.
>
> Either str(estr) performs interpolation (so billions of lines of code
> don't have to change, and my custom system()-like call get's an
> interpolated string as well until I change it to be estr-aware), or it
> does not (and billions of lines of code will break when they
> unexpectedly get an estr instead of a str).
>

Not sure I understand... your system_like() call already accepts strings that 
could be formatted?

The estr adds a protection (by escaping variables) that didn't exist in the 
past.  It is not removing any protections or best practices.  It is therefore 
safer than the f-string version, but you read additional protection as more 
dangerous, perhaps because someone in the future might get lazy.  Is that right?

But, people are already lazy (in a manner...), so it looks like a small win to me.

By "don't have to care" I don't mean we throw out best practices, only that 
doing the right thing (rephrased as, not doing the wrong thing) becomes easier, 
as Nick C. taught is a good idea in his PEP.

Any future docs certainly won't be shouting, "do this with os.system!!! It's 
safe now!!"  They will still direct to subprocess.call().
In fact I'm sorry I mentioned os.system at all, it's just a few hours ago 
someone chewed out Nick C. for using subprocess.call() in his examples.  ;)

-Mike


More information about the Python-ideas mailing list