Concatenating Strings

Terry Reedy tjreedy at udel.edu
Thu Apr 9 20:32:04 EDT 2015


On 4/9/2015 7:32 PM, Ben Finney wrote:

> Each of which is invalid syntax, because whatever was used to compose
> the message has replaced some characters.
>
>      >>> if k + ‘_@‘ in documents:
>        File "<stdin>", line 1
>          if k + ‘_@‘ in documents:
>                  ^
>      SyntaxError: invalid character in identifier

The pointer, for those whose eyes are imperfect, like mine, is off by 
one.  The problem is the codepoint 8216 inverted quote ‘, not the 
following underscore _ codepoint 95.  Remove the _ and the error 
persists, with the pointer pointing to ‘.  Ampersand @ 64 is also 
invalid, but the error persists with that removed.

 >>> Your client is composing messages that munge your text. Ensure you
 >>> post only the exact characters you want to type;

Right.  Turning ' to ‘ is a common evil of bad clients.

-- 
Terry Jan Reedy





More information about the Python-list mailing list