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

Jeremy Fincher tweedgeezer at
Sat Apr 12 11:27:15 CEST 2003

Francois Pinard <pinard at> wrote in message news:<mailman.1049836294.24621.python-list at>...
> # Python delimits a string it by single quotes preferably, unless
> # single quotes appear within the string while double quotes do
> # not, in which case it uses double quotes for string delimiters.
> # Checking the string contents, the C code stops at the first NUL.
> # We prefix the string with a single quote and a NUL, this forces
> # double quotes as delimiters for the whole prefixed string.  Then,
> # we get rid of the representation of the single quote and the NUL.
> write('"' + repr("'\0" + value)[6:])

Ah, perfect!  Thanks :)


More information about the Python-list mailing list