[Christian Tanzer] > More hmmm... > > Just grepped over my source tree (1293 .py files, ~ 300000 lines): > > - 45 occurrences of `except AttributeError` with no mention of > `TypeError` > > - 16 occurrences of `except TypeError` with no mention of > `AttributeError` > > - 3 occurrences of `except (AttributeError, TypeError)` > > Works well enough for me. With a fixed release of Python, it would be hard not to work well enough. I have to point out, though, that *across* Python releases, a frequent kind of patch made to the Python test suite is changing former TypeError occurrences to AttributeError, or vice versa. I'm not sure which direction is most common overall, and it's often unclear which is more appropriate. For example, >>> d = {} >>> d.update('abc') Traceback (most recent call last): File "<stdin>", line 1, in ? AttributeError: keys >>> I wouldn't be surprised if that changed to TypeError someday. > Deriving both AttributeError and TypeError from a common base would > make sense to me. Merging them wouldn't. Yes -- and we should derive all exceptions from LookupError <wink>.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4