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.

classification
Title: The backslash escape doesn't concatenate two strings in one in the with statement
Type: behavior Stage:
Components: Interpreter Core Versions: Python 3.1
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, py.user
Priority: normal Keywords:

Created on 2011-08-03 03:40 by py.user, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg141596 - (view) Author: py.user (py.user) * Date: 2011-08-03 03:40
>>> with open('/etc/passwd') as f1, \
...      open('/etc/profile) as f2:
  File "<stdin>", line 2
    open('/etc/profile) as f2:
                             ^
SyntaxError: EOL while scanning string literal
>>>

>>> with open('/etc/passwd') as f1,          open('/etc/profile') as f2:
...

working example for a loop:

>>> for i, j in zip(range(10), \
...                 range(5, 15)):
...   print(i, j)
... 
0 5
1 6
2 7
3 8
4 9
5 10
6 11
7 12
8 13
9 14
>>>

>>> for i, j in \
...             zip(range(10), range(5, 15)):
...   print(i, j)
... 
0 5
1 6
2 7
3 8
4 9
5 10
6 11
7 12
8 13
9 14
>>>
msg141597 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2011-08-03 04:19
Why would you expect that to concatenate strings? You have an unterminated quote?
msg141598 - (view) Author: py.user (py.user) * Date: 2011-08-03 05:01
yes, you're right, this is my mistake
History
Date User Action Args
2022-04-11 14:57:20adminsetgithub: 56894
2011-08-03 05:01:30py.usersetmessages: + msg141598
2011-08-03 04:19:51benjamin.petersonsetstatus: open -> closed

nosy: + benjamin.peterson
messages: + msg141597

resolution: not a bug
2011-08-03 03:40:57py.usercreate