[Python-Dev] Re: Update PEP 292

Raymond Hettinger python at rcn.com
Fri Aug 20 06:17:12 CEST 2004



> -----Original Message-----
> From: python-dev-bounces+python=rcn.com at python.org [mailto:python-dev-
> [Tim]
> >> 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
> >>      unchanged.
> >>
> >> 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.

. . .

raise ValueError("unsubstitutable $ at index %d" % mo.start(4))
> 
> In return for that new line, I'll never have to worry about typing
> "${barry)-rulz!" by mistake (depending on the font you're using, you
> may or may not have a hard time seeing the typo in that -- and
> assuming I didn't intend "${barry)-rulz!" to be the output too, which
> it as things are now).

That was a good example.

However, I think we should follow Cheetah's example.  That's makes it
less of a pita when the template naturally contains dollar signs with
numbers:

Template("Dear ${donor}, send $100.00 to the PSF template fund.")



Raymond




More information about the Python-Dev mailing list