[Python-ideas] Custom string prefixes
Guido van Rossum
guido at python.org
Mon May 27 19:14:46 CEST 2013
On Mon, May 27, 2013 at 9:59 AM, Ned Batchelder <ned at nedbatchelder.com> wrote:
> Implicit in your idea is that the plain literal creates a string of some
> kind, and but the r-prefixed string would apply some user-land function to
> the string. But there is no function you can apply to string literals to
> make them be raw. The r prefix suppresses interpretation that happens in
> un-prefixed strings. By the time a user-land function got hold of the
> string, the interpretation has already been done, information has already
> been lost.
I'm not sure what to think of the whole proposal (except that it
sounds Perl-ish :-), but this particular issue is easily dealt with:
let the representation sent into the function always be the raw form.
Then the 'r' prefix could be a no-op, while the default prefix would
interpret escapes.
--
--Guido van Rossum (python.org/~guido)
More information about the Python-ideas
mailing list