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

Tim Evans t.evans at paradise.net.nz
Wed Apr 9 07:43:59 EDT 2003


tweedgeezer at hotmail.com (Jeremy Fincher) writes:

> The topic really says it all -- I'd like to *force* repr(aString) to
> use double quotes.  Is that possible?
> 
> If it's not, then is it possible to achieve the same thing (everything
> escaped properly, etc.) through other means?
> 
> Thanks,
> Jeremy

def drepr(s):
    return '"' + s.encode('unicode_escape').replace('"', '\\"') + '"'

-- 
Tim Evans




More information about the Python-list mailing list