RFC PEP candidate: q'<delim>'quoted<delim> ?

Greg Ewing greg at cosc.canterbury.ac.nz
Thu Mar 7 21:54:29 EST 2002


Bengt Richter wrote:
> 
> The problem is to do it by using an existing source of text, without
> changing the text, and without using an external file to delimit it.

Even something like q'delim' doesn't allow you to
easily use completely arbitrary text, because you 
still have to pick *some* string that doesn't occur 
in the text. Although you don't have to modify the
text, you do have to inspect it in order to choose
a suitable delimiter.

I have another idea that doesn't suffer from that
problem.

  def string my_string:
    This is a free-form string constant. Its value consists
    of all the text at this indentation level, verbatim,
    with the indentation stripped off. It can contain
    ', ", ''', """, \ or any other characters.

-- 
Greg Ewing, Computer Science Dept, University of Canterbury,	  
Christchurch, New Zealand
To get my email address, please visit my web page:	  
http://www.cosc.canterbury.ac.nz/~greg



More information about the Python-list mailing list