[Tutor] recursive problem

Roelof Wobben rwobben at hotmail.com
Sun Sep 12 21:58:22 CEST 2010

> To: tutor at python.org
> From: alan.gauld at btinternet.com
> Date: Sun, 12 Sep 2010 20:52:06 +0100
> Subject: Re: [Tutor] recursive problem
> "Roelof Wobben" wrote
>>>> I guess the question to ask/consider is: How can be establish
>>>> whether a
>>>> particular object supports a particular interface/set of
>>>> behaviours
> In general we "try" it and handle the exceptions
>>>> that we require? E.g. how do we most pythonically check whether
>>>> some
>>>> object "walks like a list" and "quacks like a list" without tying
>>>> such
>>>> code to explicit type checking?
> But the risk is that although it may quack, it does so like a missile
> launch program rather than a list - oops! :-)
>> With the knowlegde I have from the few chapters of thinking like
>> a computer scientist I don't know the answer to the last question.
> If you do need to avoid accidentally launching missiles then you need
> to do some type checking - although ideally using isinstance() instead
> of type(). But in the majority of cases some sensible documentation
> and Python's culture that we are all adults here usually means you
> don't
> need to.
> HTH,
> --
> Alan Gauld
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
Hello Alan, 
The last chapter I don't understand completly.
Do i have no need for type checking or make use of isinstance() or do I misunderstood you.
Sorry that English is not a language I speak very well.


More information about the Tutor mailing list