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
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/
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
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
> 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
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':