
May 18, 2011
12:07 p.m.
On 18 May 2011 00:41, Chris Rebert <pyideas@rebertia.com> wrote:
On Tue, May 17, 2011 at 7:14 AM, dag.odenhall@gmail.com <dag.odenhall@gmail.com> wrote:
Excuse me if this has already been discussed, but couldn't __instancecheck__ be used to add exception types that match with more precision?
Somewhat related bug: http://bugs.python.org/issue12029
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'.