On 2007-12-05, Bruno Desthuilliers
<[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] a écrit :
>> Is it possible to find out if an object is of a certain type
>> or of a type derived from this type?
>
> You have the answer, thanks to Diez and Christian. Now unless
> you have a *very* compelling reason to check the type of an
> object, *just forget about it*. 9 times out of 10, this is
> fighting against the language's type system (hint: google for
> "duck typing").

As I understand Python practice (and this is pretty limited, so
corrections or other use cases are welcome), type checking is
useful for overloading functions by argument type, e.g.,
__getitem__, which accepts both integers and slice objects as
keys for sequence types. Although in the case of __getitem__, et
al, it seems like the key type could have been unified to slices
(except I suppose the return type also change, er... except for
strings--oh never mind).

-- 
Neil Cerutti
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to