Concatenating Strings

Ben Finney ben+python at benfinney.id.au
Thu Apr 9 19:32:13 EDT 2015


Chris Angelico <rosuav at gmail.com> writes:

> On Fri, Apr 10, 2015 at 4:46 AM, Ben Finney <ben+python at benfinney.id.au> wrote:
> > Your client is composing messages that munge your text. Ensure you
> > post only the exact characters you want to type; the above is not
> > valid Python code (try it yourself).
>
> I don't think they were meant to be one block. They're three
> independent examples.

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
    >>> timeKey = k + ‘_@‘
      File "<stdin>", line 1
        timeKey = k + ‘_@‘
                       ^
    SyntaxError: invalid character in identifier
    >>> historyKey = thingID + ‘_’ + k
      File "<stdin>", line 1
        historyKey = thingID + ‘_’ + k
                                 ^
    SyntaxError: invalid character in identifier

If those characters are not the same as what the original poster is
seeing, then the rest of us should not be guessing about any of the
characters in that code.

Essential to asking for help with some program code is using tools that
reliably transmit the exact same characters to whoever one is asking for
help.

-- 
 \     “Nothing worth saying is inoffensive to everyone. Nothing worth |
  `\    saying will fail to make you enemies. And nothing worth saying |
_o__)            will not produce a confrontation.” —Johann Hari, 2011 |
Ben Finney




More information about the Python-list mailing list