From 27bb014f638f9836b16366a0b535a13a218d24dd 2011-05-17 21:02:20 From: Thomas Kluyver Date: 2011-05-17 21:02:20 Subject: [PATCH] Neater code using getattr, as suggested by MinRK. --- diff --git a/IPython/core/oinspect.py b/IPython/core/oinspect.py index 5bcb2bf..48631f3 100644 --- a/IPython/core/oinspect.py +++ b/IPython/core/oinspect.py @@ -662,10 +662,8 @@ class Inspector: # from its __call__ method. if inspect.isclass(obj): - try: - callable_obj = obj.__init__ - except AttributeError: - callable_obj = None + # Old-style classes need not have an __init__ + callable_obj = getattr(obj, "__init__", None) elif callable(obj): callable_obj = obj else: