Accented cahrs in PythonWin

Robin Munn rmunn at pobox.com
Thu Jun 5 15:51:34 CEST 2003


jmdeschamps <jmdeschamps at cvm.qc.ca> wrote:
> Python 2.2.2
> PythonWin build 152
> 
> in the interactive window:
>>>> toto = "été

Huh? That should *not* have worked. You should have gotten a
"SyntaxError: invalid token" because of having no closing quote.

>>>> # accepted string assignment but can't see the last quote
>>>> print toto
> ét
>>>> # where is the last quote ???

When you print a string, Python renders it without any quotes around it;
notice that there was no opening quote either. The disappearance of the
acute e makes me wonder also. The only explanation I can come up with
for both these events is that the interpreter somehow took that second
acute e to be a quote character. This the 'toto = "été' line was
interpreted as 'toto = "ét"'. I can't think of a reason why that would
happen, but it would explain the absence of a SyntaxError.

>>>> toto
> '\xe9t\xe9'

Notice the opening and closing quotes. This is the repr() of the string,
as opposed to the str() of the string. If I'm confusing you with this
paragraph, read up on repr() and str() at:

    http://www.python.org/doc/current/lib/built-in-funcs.html

>>>> # here are 3 chars
> 
> BUT pasted here as:
>>>> toto = "été"
>>>> # accepted string assignment but can't see the last quote
>>>> print toto
> été
>>>> # where is the last quote ???

No opening or closing quotes -- this is normal.

>>>> toto
> '\xe9t\xe9'

Also normal.

-- 
Robin Munn <rmunn at pobox.com>
http://www.rmunn.com/
PGP key ID: 0x6AFB6838    50FF 2478 CFFB 081A 8338  54F7 845D ACFD 6AFB 6838




More information about the Python-list mailing list