On 10/11/06, Ben Finney <[EMAIL PROTECTED]> wrote: > "Theerasak Photha" <[EMAIL PROTECTED]> writes:
> Far better is to take the objects passed, *use* them in the way that > you need to use them, and catch exceptions that get raised at the > point where there is enough context to handle them. This is the > "Easier to Ask Forgiveness than Permission" (EAFP) principle, and it > is considered to be far more Pythonic. Again, someone asked me to write the code for him in a personal response to a previous thread. I simply executed his wishes (albeit poorly). I knew about EAFP before Python; in Ruby we have 'duck typing' and there's a whole chapter about its virtues in Pick Axe. Myself I am a strong proponent of this method, also known in OO Perl lingo, which I know well, as interface polymorphism (Conway). The main reason I *didn't* grok isinstance was b/c I never really thought to use it before... :) -- Theerasak -- http://mail.python.org/mailman/listinfo/python-list