[Python-Dev] Re: Yet another string formatting proposal

Chermside, Michael mchermside@ingdirect.com
Fri, 22 Nov 2002 13:49:05 -0500

> > I'm also bit dubious about the name "cook" (cute though!).=20
> The rationale behind the name wasn't just "cuteness". The effect
> of this method is the exact opposite of the "raw" prefix so the
> name "cook" was the most natural and descriptive choice. Got any
> other ideas?

But I don't think that it IS the opposite of the "raw" prefix. In
a case with just substitutions like this, it works:

>>> x =3D 5
>>> s1 =3D ":\{x}:"
>>> s1
>>> s2 =3D r":\{x}:"
>>> s2
>>> s2.cook()

But in a case where OTHER escapes are used, it wouldn't be:

>>> x =3D 5
>>> s1 =3D "\t\{x}"
>>> print s1
>>> s2 =3D r"\t\{x}"
>>> print s2
>>> print s2.cook()

You could "fix" this by ALSO processing \ escapes in the cook()
method, but that confuses two very different processes and would
only make the feature MORE difficult to use.

Of course, now that I knock your idea down, I'd better come up
with a replacement of my own. I suggest ".sub()" from PEP 292
(after all... let's try to build on what was developed in the
previous discussions).

> > +1 (but, of course, that vote doesn't count until there's a PEP
> > to refer to).
> Just wanted to sample the water first. I bet everyone is already=20
> sick of this subject after two PEPs, several other proposals, endless=20
> discussions and no results.

Yes, but the reason for so many discussions is that it's an issue
which actually matters. So long as new ideas BUILD on existing
ones, we're making progress. This is one of those cases where the
implementation is trivial, but designing it right... ah, that's

-- Michael Chermside