Preventing 'bad' filenames from raising errors in os.path

"Martin v. Löwis" martin at v.loewis.de
Fri May 2 13:50:39 EDT 2008


> Now, I can understand if you don't like the "WindowsError" as that is
> obviously platform specific. The try/except pattern however is the way
> errors are handled in python and the best and most appropriate way to
> deal with it. The above example just shows that at the very least
> there isn't a significant difference in code size between the two
> methods.
> 
> I don't know what the equivalent error is called in *nix but assume it
> is PosixError (it isn't)

The common base class to use here is actually OSError. WindowsError is
a subclass thereof.

Regards,
Martin



More information about the Python-list mailing list