
On Wed, May 18, 2011 at 6:07 AM, dag.odenhall@gmail.com <dag.odenhall@gmail.com> wrote:
Interesting. If that is intentional I'd advocate against it unless there's a strong argument for it.
Another idea (also likely already proposed) would be to match against instances as well, by the 'args' attribute:
try: ... except IOError(32): # isinstance IOError and .args == (32,) ...
If this seems crazy consider that it's (to some extent) similar to the behavior of 'raise'.
Unfortunately, as described it wouldn't match IOError(32, 'Blah blah blah'). Although maybe it makes sense to create an Anything builtin, which is equal to everything, such that IOError(X, Y) == IOError(X, Anything) == IOError(X, Z) for all X, Y, and Z (except stupid X like X = nan). I do like it. Devin Jeanpierre