The following code yields a number of errors in pydev code analysis:
with open('tmp.txt', 'w') as file:
I get "undefined variable" for 'with' and 'as', and that 'open' was unexpected. My eclipse project is set to use Python 2.5 grammar.
Is the above construct not supported in pydev? Or am I doing something wrong?
Python 2.5 doesn't support the with statement unless you add an import for it (Python 2.6 onwards doesn't require it):
from __future__ import with_statement
I was running this code on python 2.6, so I didn't get an error. Importing with_statement from the future solved the issue. ;-)