On Sun, Mar 25, 2012 at 12:54 PM, Michael Lewis <mjole...@gmail.com> wrote:
> In the below block, why is the if statement e.errno != errno.EEXIST?
> Why can the errno be both before and after the "."?
>
>
>
> import os, errno
> try:
>     os.makedirs('a/b/c')
> except OSError, e:
>     if e.errno != errno.EEXIST:
>         raise

errno is a dictionary of standard errors.  You can learn about it in
the python shell by importing errno then typing help(errno) or
dir(errno).  So, errno.EEXIST is just the number 17 as it turns out

e is an exception object.  It has an attribute called errno which
identifies what the error number is.  So this is just comparing what
your actual error is to the EEXIST number.  If it isn't that, then you
'raise'


>
>
> --
> Michael J. Lewis
>
> mjole...@gmail.com
> 415.815.7257
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>



-- 
Joel Goldstick
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to