Jon-Eric
Jon-Eric

Reputation: 17285

What's the point of os.error?

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?

Upvotes: 7

Views: 1597

Answers (1)

Joey
Joey

Reputation: 354724

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.

Upvotes: 6

Related Questions