Is there any way to make repr(aString) use double quotes?

Lulu of the Lotus-Eaters mertz at
Tue Apr 8 22:18:00 CEST 2003

"Mike C. Fletcher" <mcfletch at> wrote previously:
|>    '"%s"' % repr(aString)[1:-1]
|Except when there's a " character in the string ;) .

Ahh... what I MEANT to write was, of course:

    '"%s"' % repr(aString)[1:-1].replace('"',r'\"')

Emphasizing the "not pretty" part further.  (I still think it is
prettier than Mike's though :-)).

Btw. The OP wrote "string", so obviously I am not interested in

Yours, Lulu...

    _/_/_/ THIS MESSAGE WAS BROUGHT TO YOU BY: Postmodern Enterprises _/_/_/
   _/_/    ~~~~~~~~~~~~~~~~~~~~[mertz at]~~~~~~~~~~~~~~~~~~~~~  _/_/
  _/_/  The opinions expressed here must be those of my employer...   _/_/
 _/_/_/_/_/_/_/_/_/_/ Surely you don't think that *I* believe them!  _/_/

More information about the Python-list mailing list