[Zope] Double quotes in (Python) strings (was: Problem with escaped double quotes)

Dieter Maurer dieter@handshake.de
Sun, 19 Nov 2000 20:14:55 +0100 (CET)


Inside Python strings, i.e. inside expr="'...'", you
can use "\042" or "\x22" to embed a '"'.

How it works:

  Python recognizes various escapes inside strings.
  Usually, they are used to insert characters that otherwise
  are difficult to include (usually, because they are unprintable
  or there is not widely knows key on the standard keyword).

  For your purpose, two escape types are interesting:
  octal escapes and hexadecimal excapes.
  An octal escape is a "\" followed by up to 3 octal digits.
  The octal digits are interpreted as an octal number
  defining the code of the character to be embedded.
  A hexadecimal excape is a "\x" followed by a sequence
  of hexadecimal digits. Python takes the last two digits,
  interprets it as a hexadecimal number defining the code
  of the character to be embedded.

  The code for '"' is octal 042 and hexadecimal 0x22.


Dieter