sufficiently pythonic code for testing type of function

Theerasak Photha hanumizzle at gmail.com
Wed Oct 11 05:13:54 EDT 2006


On 10/11/06, Fredrik Lundh <fredrik at pythonware.com> wrote:

> can be a lot better than a 30-level traceback that ends with a line
> looking something like
>
>      fnut.index(gah)

Despite long experience with Perl, I am not a big follower of the
"goose_level: blah" method of error reporting...

> also, checking for __method__ is, in general, not the right way to check
> if an object implements a given interface.

I had a vague feeling it might not be a Right Thing(tm).
<flame-proof-underwear>I kind of miss
responds_to?</flame-proof-underwear>

> so if you can, try doing the operation instead, and catch error (if you
> really need to check first, use an idempotent operation, if available).

I'll do that as soon as my green noggin figures out what 'idempotent' means.

Serves me right for being a liberal arts weenie:
http://www.c2.com/cgi/wiki?ThaiLanguage

-- Theerasak



More information about the Python-list mailing list