python-dev Summary for 2004-02-01 through 2004-02-29
Roger Binns
rogerb at rogerbinns.com
Thu Mar 18 02:18:12 EST 2004
> > Why would you need to dynamically add exceptions? My mind
> > is beginning to boggle trying to find a use case for this.
I do it. I have some code that talks to pySerial. On Windows
it can throw an exception type that is part of win32all and
hence not present on other platforms.
modeignoreerrortypes=[ commport.CommTimeout,
common.CommsDeviceNeedsAttention ]
try:
import pywintypes
modeignoreerrortypes.append(pywintypes.error)
except:
pass
# has to be tuple or it doesn't work
modeignoreerrortypes=tuple(modeignoreerrortypes)
Later on in my code I detect a broken driver (most of the
time I am actually talking to USB to serial connections).
When that happens it starts giving dud exceptions which
I add to the above list (I only want to do it for the
broken driver, not all cases).
Roger
More information about the Python-list
mailing list