6.2 StringsStrings can be enclosed either in single (’) or double (") quotes. Strings may also be enclosed by three quote characters in a row: either ’’’ or """. Special care needs to be taken when using apostrophes or quotes in single-quote delimited strings, as these characters may be misinterpreted as string delimiters, as in the example:
This easiest way to avoid such problems is to use three quotes:
Special characters such as tabs and newlines can be inserted into strings using escape codes such as pyxplot> print e’the moon, Sometimes these escape codes can be rather annoying, especially when entering latex control codes, which all begin with backslash characters. Rather than having to escape every backslash, it is generally easier to prefix the string with the character r, which turns off all escape codes: pyxplot> print r”’I escaped the quote by typing
Table 6.1: A complete list of Pyxplot’s string escape sequences. These are a subset of those available in C. Once defined, a string variable can be used anywhere in Pyxplot where a quoted string could have been used, for example in the set title command: plotname = "Insert title here" set title plotname Strings can be concatenated together using the + operator: pyxplot> print "pi = " + pi.str()
|