Exception handling wart in Python

Tim Peters tim.one at home.com
Fri Nov 2 14:26:27 EST 2001


[Leo Lipelis]
> ...
> But how about here:
>
> ---begin script---
>     def foo(frob):
>         x = frob.mumble()

You can stop right there:  at this point you have to be prepared to handle
every exception, as the underlying getattr(frob, "mumble") lookup can
execute any code whatsoever (especially if frob defines a __getattr__ hook).
There's nothing else useful to be said about this, including:

> At some point you do know the type.  You just have to infer it.

At least you've reduced it to a simpler problem <wink>.

i'll-post-again-when-the-type-inferencer-patch-shows-up-ly y'rs  - tim





More information about the Python-list mailing list