Re: Question about using "with"

2007-01-09 Thread Duncan Booth
Laszlo Nagy <[EMAIL PROTECTED]> wrote: > >> >> 591 > ./cat.py cat.py >>File "./cat.py", line 6 >> with open(sys.argv[nn]) as f: >> ^ >> SyntaxError: invalid syntax >> 592 > >> >> This example came from http://docs.python.org/tut/node10.html down in >> section 8.7 >> >> Am I

Re: Question about using "with"

2007-01-09 Thread Peter Otten
Steven W. Orr wrote: >>From the tutorial, they said that the following construct will > automatically close a previously open file descriptor: > > --- > #! /usr/bin/python > import sys > > for nn in range ( 1, len(sys.argv ) ): > print "arg ", nn, "value = ", sys.argv[nn] >

Re: Question about using "with"

2007-01-09 Thread Steven Bethard
Steven W. Orr wrote: >> From the tutorial, they said that the following construct will > automatically close a previously open file descriptor: > > --- > #! /usr/bin/python > import sys > > for nn in range ( 1, len(sys.argv ) ): > print "arg ", nn, "value = ", sys.argv[nn] >

Re: Question about using "with"

2007-01-09 Thread Laszlo Nagy
> > 591 > ./cat.py cat.py >File "./cat.py", line 6 > with open(sys.argv[nn]) as f: > ^ > SyntaxError: invalid syntax > 592 > > > This example came from http://docs.python.org/tut/node10.html down in > section 8.7 > > Am I missing something? > Are you using python 2.5? The

Question about using "with"

2007-01-09 Thread Steven W. Orr
>From the tutorial, they said that the following construct will automatically close a previously open file descriptor: --- #! /usr/bin/python import sys for nn in range ( 1, len(sys.argv ) ): print "arg ", nn, "value = ", sys.argv[nn] with open(sys.argv[nn]) as f: