At 10:00 AM 5/13/03 +1000, Delaney, Timothy C (Timothy) wrote: >I can't think of any case in *my* code where I would want to distinguish >between a TypeError and an AttributeError - usually I end up having: > > try: > ... > except (TypeError, AttributeError): > ... How odd. I was going to say the reverse; that I *always* want to distinguish between the two, because TypeError almost invariably is a programming error of some kind, while AttributeError is nearly always an error that I'm checking in order to have a fallback. E.g.: try: foo = thingy.foo except AttributeError: # default case else: foo() However, if 'thingy.foo' were to raise any other kind of error, such as a TypeError, it'd probably mean that thingy had a broken 'foo' descriptor that I'd want to know about.
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