I am trying to read from one file and write to another file using:
with open('example2') as inpf, open('outputrt','w') as outf:
for l in inpf:
outf.write(l)
But I am getting a syntax error at the line 1 i.e.
"with open('example2') as inpf, open('outputrt','w') as outf:" pointing at "inpf,"
My python version is 2.6. Is there an error in syntax?
That syntax is only supported in 2.7+.
In 2.6 you can do:
Or it might look cleaner to you to do this (this would be my preference):