tags:

views:

132

answers:

1

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?

+3  A: 

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.

Joey
Yep. And -- we overlooked this detail in the move to Python 3, so os.error is _still_ there even in 3.1 (oops -- probably too late to fix now... sorry!).
Alex Martelli