Re: Built-in Exceptions - How to Find Out Possible Errno's

2006-07-05 Thread Justin Azoff
Gregory Piñero wrote: > Hi Guys, > > I'm sure this is documented somewhere, I just can't locate it. Say I > have this code: > > try: > myfile=file('greg.txt','r') > except IOError, error: [...] > So basically I'm looking for the document that tells me what possible > errors I can catch and t

Re: Built-in Exceptions - How to Find Out Possible Errno's

2006-07-05 Thread Mark Peters
A quick test: >>> try: f = open("foo","r") except IOError, error: print errno.errorcode[error.errno] ENOENT It looks to me like your if statement should be as simple as: if error.errno == errno.ENOENT: print os.strerror(error.errno) Mark -- http://mail.python.org/mailman/

Re: Built-in Exceptions - How to Find Out Possible Errno's

2006-07-05 Thread Mark Peters
Gregory Piñero wrote: > Thanks Mark, that does help, but what is this errno module? I mean, > does it apply to OSError or to IOError or both? My guess is that the IOError will return the underlying operating system error, but that's just a guess (and no time to dig for the answer right now) Mar

Re: Built-in Exceptions - How to Find Out Possible Errno's

2006-07-05 Thread Gregory Piñero
Thanks Mark, that does help, but what is this errno module? I mean, does it apply to OSError or to IOError or both? On 5 Jul 2006 14:44:28 -0700, Mark Peters <[EMAIL PROTECTED]> wrote: > > I did find this but it doesn't have numbers and I can't tell if it's > > even what I'm looking for: > > http

Re: Built-in Exceptions - How to Find Out Possible Errno's

2006-07-05 Thread Mark Peters
> I did find this but it doesn't have numbers and I can't tell if it's > even what I'm looking for: > http://docs.python.org/lib/module-errno.html Error number picked at random: >>> import errno >>> print errno.errorcode.keys() [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20, 2

Built-in Exceptions - How to Find Out Possible Errno's

2006-07-05 Thread Gregory Piñero
Hi Guys, I'm sure this is documented somewhere, I just can't locate it. Say I have this code: try: myfile=file('greg.txt','r') except IOError, error: #now psuedo code because this is what I'm trying to figure out if error.errno=='file doesn't exist':