escaping/encoding/formatting in python

rusi rustompmody at gmail.com
Fri Apr 6 09:22:13 EDT 2012


On Apr 6, 1:52 pm, Nobody <nob... at nowhere.com> wrote:
> On Thu, 05 Apr 2012 22:28:19 -0700, rusi wrote:
> > All this mess would vanish if the string-literal-starter and ender
> > were different.
>
> You still need an escape character in order to be able to embed an
> unbalanced end character.
>
> Tcl and PostScript use mirrored string delimiters (braces for Tcl,
> parentheses for PostScript), which results in the worst of both worlds:
> they still need an escape character (backslash, in both cases) but now you
> can't match tokens with a regexp/DFA.

Yes. I hand it to you that I missed the case of explicitly unbalanced
strings.
But are not such cases rare?
For example code such as:
print '"'
print str(something)
print '"'

could better be written as
print '"%s"' % str(something)



More information about the Python-list mailing list