fredrik at pythonware.com
Mon Mar 6 18:24:42 CET 2006
"Blackbird" <fake at nospam.no> wrote:
> >> [...]
> >>>> 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'
> Excellent counterexample. Can something like this happen for other things
> than quotes?
>>> a = '\377'
>>> print '%r' % a
>>> a = r'\377'
>>> print "'%s'" % a
I still recommend looking up %s and %r and str() and repr() in the
documentation. it's not hard to understand what they do, and that
approach works a bit better than cargo cult programming.
More information about the Python-list