Re: Catching a specific IO error

2007-04-25 Thread Tina I
Gabriel Genellina wrote: > You can get the 2 as the errno exception attribute. BTW, 2 == errno.ENOENT > > try: > export = open(self.exportFileName , 'w') > except IOError, e: > if e.errno==errno.ENOENT: > # handle the "No such file or directory" error >

Re: Catching a specific IO error

2007-04-24 Thread John Machin
On 25/04/2007 4:06 AM, Steven Howe wrote: > Steve Holden wrote: >> Thomas Krüger wrote: >> >>> Tina I schrieb: >>> Now, this works but of course it catches every IOError, and I can not figure out how to restrict it to only catch the "[Errno 2]"? >>> There's an example th

Re: Catching a specific IO error

2007-04-24 Thread Michael Hoffman
Steven Howe wrote: > Steve Holden wrote: >> Thomas Krüger wrote: >> >>> Tina I schrieb: >>> Now, this works but of course it catches every IOError, and I can not figure out how to restrict it to only catch the "[Errno 2]"? >>> There's an example that uses the error numbe

Re: Catching a specific IO error

2007-04-24 Thread Steven Howe
Steve Holden wrote: > Thomas Krüger wrote: > >> Tina I schrieb: >> >>> Now, this works but of course it catches every IOError, and I can not >>> figure out how to restrict it to only catch the "[Errno 2]"? >>> >> There's an example that uses the error number: >> http://docs.python.or

Re: Catching a specific IO error

2007-04-24 Thread Steve Holden
Thomas Krüger wrote: > Tina I schrieb: >> Now, this works but of course it catches every IOError, and I can not >> figure out how to restrict it to only catch the "[Errno 2]"? > > There's an example that uses the error number: > http://docs.python.org/tut/node10.html#SECTION001030

Re: Catching a specific IO error

2007-04-24 Thread Gabriel Genellina
En Tue, 24 Apr 2007 08:44:05 -0300, Tina I <[EMAIL PROTECTED]> escribió: > Hi group :) > > I have this standard line: > > export = open(self.exportFileName , 'w') > > 'exportFileName' is a full path given by the user. If the user gives an > illegal path or filename the following exceptio

Re: Catching a specific IO error

2007-04-24 Thread Thomas Krüger
Tina I schrieb: > Now, this works but of course it catches every IOError, and I can not > figure out how to restrict it to only catch the "[Errno 2]"? There's an example that uses the error number: http://docs.python.org/tut/node10.html#SECTION001030 Thomas -- sinature: http://

Catching a specific IO error

2007-04-24 Thread Tina I
Hi group :) I have this standard line: export = open(self.exportFileName , 'w') 'exportFileName' is a full path given by the user. If the user gives an illegal path or filename the following exception is raised: "IOError: [Errno 2] No such file or directory: /some/path/file.txt" So at