On 08/26/2011 11:49 AM, Prasad, Ramit wrote:
<snip>
Yep, it is. Thanks those charts are exactly what I wanted! Now I have another 
question. What is the difference between what print shows and what the 
interpreter shows?

print s.decode('latin-1')
MÉXICO
The decoded characters are a Unicode string. Python prints that string by encoding it according to whatever sys.stdout is defaulted to. If that matches your actual terminal, then you see it properly.
s.decode('latin-1')
u'M\xc9XICO'
Here, because you don't assign it to anything, the interpreter is printing a repr() of the object.
print repr(s)
'M\xc9XICO'
Here your code is doing the same thing, but explicitly this time.
repr(s)
"'M\\xc9XICO'"


Here, the repr() is created (which is a string containing single quotes), but then you don't print it, you just leave it. So the interpreter shows you the repr() of that object, enclosing it in double quotes for simplicity.



--

DaveA

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to