RE: [Python-Dev] Re: Yet another string formatting proposal
I'm also bit dubious about the name "cook" (cute though!).
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 = 5 s1 = ":\{x}:" s1 ':5:' s2 = r":\{x}:" s2 ':\{x}:' s2.cook() ':5:'
But in a case where OTHER escapes are used, it wouldn't be:
x = 5 s1 = "\t\{x}" print s1 5 s2 = r"\t\{x}" print s2 \t# print s2.cook() \t5
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 sick of this subject after two PEPs, several other proposals, endless 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 HARD. -- Michael Chermside
On Fri, Nov 22, 2002 at 01:49:05PM -0500, Chermside, Michael wrote:
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.
But I don't think that it IS the opposite of the "raw" prefix. In ... But in a case where OTHER escapes are used, it wouldn't be: ... 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.
In case it wasn't clear from my posting this is exactly what I propose. Otherwise how would you convert the following run-time embedding to a compile-time template? u"Resistance = \{resistance} \N{GREEK CAPITAL LETTER OMEGA}\n" If cooking did not process ALL escape sequences you would not be able to just change the 'u' prefix to 'ur' and cook it later. I don't think it makes it more difficult to use. NOT processing escapes would be inconsistent and make it difficult to use. Oren
participants (2)
-
Chermside, Michael
-
Oren Tirosh