[Baypiggies] Crossplatform exceptions.WindowsError help
Shannon -jj Behrens
jjinux at gmail.com
Tue Apr 22 13:03:27 CEST 2008
On Mon, Apr 14, 2008 at 6:17 PM, Paul McNett <p at ulmcnett.com> wrote:
> Aahz wrote:
> > On Mon, Apr 14, 2008, Paul McNett wrote:
> >> Hi,
> >>
> >> This code must run cross-platform:
> >>
> >> try:
> >> ..
> >> except WindowsError:
> >> ..
> >>
> >> However, the WindowsError exception is only defined on Windows, not on
> >> Linux or Mac. How do I keep a spurious NameError from happening on the
> >> other platforms while still keeping the code clean (free from
> >> os-specific code blocks)?
> >
> > try:
> > WindowsError
> > except:
> > class WindowsError: pass
>
> Okay, I guess that isn't so bad after all, now that I see it in blue on
> white. Thanks!
You might want to subclass WindowsError from Exception or whatever
else it actually subclasses on Windows.
-jj
--
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/
More information about the Baypiggies
mailing list