WindowsError is not available on linux?

MRAB python at mrabarnett.plus.com
Tue Nov 17 21:44:47 EST 2009


Peng Yu wrote:
> It's not clear to me whether WindowsError is available on linux or
> not, after I read the document. But I see WindowsError in shutil.py.
> Could you somebody let me know what cause the following error?
> 
>>>> try:
> ...   raise WindowsError('WindowsError')
> ... except WindowsError as e:
> ...   print e
> ...
> Traceback (most recent call last):
>   File "<stdin>", line 3, in <module>
> NameError: name 'WindowsError' is not defined

WindowsError is for Windows-specific errors (hence the name!). You
shouldn't rely on it being defined on non-Windows machines.



More information about the Python-list mailing list