Quoting quotes

Lawrence D'Oliveiro ldo at geek-central.gen.new_zealand
Fri Feb 26 17:22:09 EST 2010


In message 
<bda4748c-49ec-4383-81c1-7baaae567180 at l19g2000yqb.googlegroups.com>, William 
Lohrmann wrote:

> The best thing would be to backslash the single quote: print 'The play
> "All\'s Well That Ends Well"'

Backslash-type escapes are the most general solution to this type of 
problem. They’re also the easiest to apply automatically:

    for ch in input_string :
         if ch in troublesome_lot :
             output backslash + tame representation of ch
         else :
             output ch
         #end if
    #end for



More information about the Python-list mailing list