2

Possible Duplicate:
Python: open multiple files using “with open”?
Does, With open() not works with python 2.6

I have seen other answers to help me with this. But I can't seem to get any of the solutions provided to work at all! Here is part of my code for it:

with open('Levels.dat', 'w') as l, open('Names.dat', 'w') as n:

I got this error:

    with open('Levels.dat', 'w') as l, open('Names.dat', 'w') as n:  
                                     ^
SyntaxError: invalid syntax 

How do I fix this?

5
  • I keep trying to help you with your formatting. Please do not keep reverting it again. Commented Dec 5, 2012 at 15:06
  • Oh sorry about that, I'm trying to make it look how it is in my code Commented Dec 5, 2012 at 15:15
  • @junyi00: The try: line is not relevant, and I reproduced your error on Python 2.6, and adjusted the syntax error traceback to match that. Commented Dec 5, 2012 at 15:27
  • 1
    You tagged this with Python 2.7, but the syntax error you see would only happen in python 2.6. Commented Dec 5, 2012 at 15:28
  • Thx for that. I always thought that I used 2.7.3, I must look at it again Commented Dec 5, 2012 at 15:42

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.