[Baypiggies] Crossplatform exceptions.WindowsError help

Aahz aahz at pythoncraft.com
Tue Apr 15 01:51:43 CEST 2008

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)?

    class WindowsError: pass
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"It is easier to optimize correct code than to correct optimized code."
--Bill Harlan

More information about the Baypiggies mailing list