[Python-Dev] os.path.walk() lacks 'depth first' option (original) (raw)

Phillip J. Eby pje@telecommunity.com
Mon, 12 May 2003 20:34:21 -0400


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.