This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2008年07月06日 13:09 by Stavros, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Messages (5) | |||
|---|---|---|---|
| msg69326 - (view) | Author: Stavros Korokithakis (Stavros) | Date: 2008年07月06日 13:09 | |
A multiline string with quotes next to the ending quote is not parsed correctly: In [1]: """A "test"""" ------------------------------------------------------------ File "<ipython console>", line 1 """A "test"""" ^ <type 'exceptions.SyntaxError'>: EOL while scanning single-quoted string Is this normal behaviour? It seems to me like the parser should parse everything inside the triple double quotes (there is no ambiguity). |
|||
| msg69327 - (view) | Author: Georg Brandl (georg.brandl) * (Python committer) | Date: 2008年07月06日 13:24 | |
There is an ambiguity: did you mean """ " or " """ (spaces added for clarity). Python does not count quotes, parentheses or similar in strings, so the first occurrence of """ will close the literal. You can either use triple single quotes, or escape the first quote, like that: """A "test\"""". |
|||
| msg69328 - (view) | Author: Stavros Korokithakis (Stavros) | Date: 2008年07月06日 13:35 | |
Hmm, what would be the meaning of """ " in this particular context? I can't think of a situation where """A test""" " would be valid code. |
|||
| msg69329 - (view) | Author: Georg Brandl (georg.brandl) * (Python committer) | Date: 2008年07月06日 13:38 | |
The last quote starts another string literal, so this is valid Python: """A "test"""" B" and results in a string 'A "test B'. The lexer cannot know whether the second string literal is terminated or not, yielding valid or invalid code. |
|||
| msg69330 - (view) | Author: Stavros Korokithakis (Stavros) | Date: 2008年07月06日 13:53 | |
Ah, interesting, I had forgotten that adjacent strings are merged. Thanks. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:36 | admin | set | github: 47548 |
| 2008年07月06日 13:53:29 | Stavros | set | messages: + msg69330 |
| 2008年07月06日 13:38:15 | georg.brandl | set | messages: + msg69329 |
| 2008年07月06日 13:35:19 | Stavros | set | messages: + msg69328 |
| 2008年07月06日 13:24:54 | georg.brandl | set | status: open -> closed resolution: not a bug messages: + msg69327 nosy: + georg.brandl |
| 2008年07月06日 13:09:47 | Stavros | create | |