Is this a bug?

Alex Martelli aleaxit at yahoo.com
Sun May 13 11:04:31 EDT 2001


"Costas Menico" <costas at meezon.com> wrote in message
news:3afe8fc0.4917276 at News.CIS.DFN.DE...
    ...
> I guess there is no perfect solution. We can do something similar to
> what ASP does. <% %>. Just dont include %> inside your string. But I
> am sure there are more important upgrades to Python than this.

I fully agree on the latter assertion.  Your proposal about <% seems
vastly inferior to me than the current raw-string, whose only limitation
is being unable to END a rawstring with an odd number of \, while in
your proposal we'd be in trouble with rawstring CONTAINING any
occurrence of the chosen terminating-substring at ANY place.

I do hope this debate resolves your personal issue that you expressed
as "I just don't understand why the parser can't be smart enough about
this".  The Python parser is "smart enough" about rawstrings to focus
anomalies into ONE, easily documented, easily understood and tested-
for issue -- zero is not achievable, and that one was craftily chosen.
Rawstrings are optimized for use as regular-expression literals, where
there is never any need for them to end with an odd number of
backslashes.  When you're generating Python code yourself, and need
a literal for an arbitrary string, repr() is probably a better choice than
any rawstring, anyway.


Alex






More information about the Python-list mailing list