WindowsError is not available on linux?

Dave Angel davea at ieee.org
Wed Nov 18 23:00:45 CET 2009



Benjamin Kaplan wrote:
> On Wed, Nov 18, 2009 at 2:53 PM, Aahz <aahz at pythoncraft.com> wrote:
>   
>> In article <mailman.599.1258510702.2873.python-list at python.org>,
>> Peng Yu  <pengyu.ut at gmail.com> wrote:
>>     
>>> It's not clear to me whether WindowsError is available on linux or
>>> not, after I read the document.
>>>       
>> Here's what I told a co-worker to do yesterday:
>>
>> if os.name ='nt':
>>    DiskError =OSError, WindowsError)
>> else:
>>    DiskError =indowsError
>>
>> try:
>>    disk_operation()
>> except DiskError:
>>    logit()
>> --
>>     
>
> Shouldn't that be the other way?
> if os.name ='nt':
>     DiskError =SError, WindowsError
> else :
>     DiskError =SError
>
>
>   
Doesn't matter.  It's not needed anyway, since WindowsError is derived 
from OSError.   So just use OSError in the except clause.

DaveA




More information about the Python-list mailing list