Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the point of os.error?

Tags:

python

Why does Python's os module contain error, an alias for OSError?

Is there a reason to ever spell it os.error? OSError certainly seems more consistent with all the other built-in exceptions.

I hoped os.py would shed some light, but it uses error sometimes and OSError others.

It seems goofy to have an extra name for one of the exceptions, yet it survives into Python 3.0. What am I missing?

like image 975
Jon-Eric Avatar asked Jun 12 '09 21:06

Jon-Eric


1 Answers

The documentation for OSError says that it was added in version 1.5.2. My guess is that error predates this a little and in an effort to remain backwards-compatible to code written for Python before 1.5.2 error was made an alias for OSError.

like image 53
Joey Avatar answered Sep 28 '22 16:09

Joey