i just started learning python yesterday and I'm trying to build a program that can navigate my Linux file system. I found this code online which works fine, but I don't understand the exception handling. The format of a try block is
errors = []
try
...
except OSError as why:
errors.append((srcname, dstname, str(why)))
except Error as err:
errors.extend(err.args[0])
I can't find any description of an 'Error' type of exception. I can however find a description of 'OSError' in the python docs. Is 'Error' used to refer to any type of exception?
Error is likely to have been defined as a custom class for exceptions. In fact, it's tradition to define Error as the base class for all custom exceptions.
For more information, see this python doc:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With