En Tue, 06 Feb 2007 22:18:07 -0300, Sick Monkey <[EMAIL PROTECTED]> escribió:
> I have never seen this "with open(fname,'r') as finput:" > > It is actually throwing an error . Do I have to import a special > library to > use this? > > File "dictNew.py", line 23 > with open(fname,'r') as finput: > ^ > SyntaxError: invalid syntax Oh, sorry. You need two things: - Python 2.5 - include this line at the very beginning of your script: from __future__ import with_statement If you're using an earlier version, you can write: finput = open(fname,'r') try ... finally finput.close() (Or just omit the try/finally and rely on the garbage collector, but it's not the recommended practice, specially when external resources are involved, like files). -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list