Re: %r
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: %r

From: Duncan Booth <duncan.booth@invalid.invalid>
Date: Mon Mar 06 2006 - 17:51:22 CET

Blackbird wrote:

> I'm trying to get a complete grip on %r. Is it true that the two
> programs
>
> a = '*anything the parser accepts*'
> print '%r' % a
>
> vs.
>
> a = r'*anything the parser accepts*'
> print "'%s'" % a
>
> always produce the same output, where *anything the parser accepts*
> can be replaced with, well, anything the parser accepts?

>>> a = 'I don\'t think so'
>>> print '%r' % a
"I don't think so"
>>> a = r'I don\'t think so'
>>> print "'%s'" % a
'I don\'t think so'
Received on Sun Apr 30 10:59:03 2006