[Python-Dev] Re: Update PEP 292
bac at OCF.Berkeley.EDU
Fri Aug 20 01:12:54 CEST 2004
Barry Warsaw wrote:
> On Thu, 2004-08-12 at 01:19, Tim Peters wrote:
>>I do object to this part:
>> If the $ character appears at the end of the line, or is followed
>> by any other character than those described above, it is treated
>> as if it had been escaped, appearing in the resulting string
>>There's already a facility to escape $, and it's dead easy to use. $
>>isn't a frequently needed character either in most apps. So escaping
>>$ "by magic" too is, I think, more likely to make typing errors harder
>>to find than to do anyone real good.
> What would you do about $'s at the end of the string? I think the
> implementation would be much more complex if you didn't have this rule,
> e.g. you'd have to match \$$ and the $-placeholder regexps would
> basically have to match everything. Then the .sub call would have to be
> more complex too, because it would have to check for the existence of
> those match groups and then raise an exception. Or something like that.
Got an implementation and it's simple. =) It only required one
additional group at the end (r"(?<!\$)(\$)$") in the regex and a test if
I tested against "$$" to be fine but for "blah $" and "$" to raise an
exception. Those all work and the tests in test_pep292 all pass.
If Barry is okay with this I can apply the patch and update the tests
and the PEP. Do need to know what exception to raise when this does
occur, though. ValueError?
More information about the Python-Dev