In recent versions of Python, hasattr() only catches AttributeError. This catches all errors.
(obj, attr)
| 10 | |
| 11 | |
| 12 | def safe_hasattr(obj, attr): |
| 13 | """In recent versions of Python, hasattr() only catches AttributeError. |
| 14 | This catches all errors. |
| 15 | """ |
| 16 | try: |
| 17 | getattr(obj, attr) |
| 18 | return True |
| 19 | except: |
| 20 | return False |
| 21 | |
| 22 | |
| 23 | def dir2(obj): |
no outgoing calls
no test coverage detected