An Object's Type

paul paul at subsignal.org
Thu Dec 6 06:52:15 EST 2007


Bruno Desthuilliers schrieb:
> bg_ie at yahoo.com a écrit :
>> Hi,
>>
>> 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").
So I have to give up the concept that argument types are part of the 
interface or signature? Honestly, I don't like that. Granted; not having 
strict type checking makes for great flexibility but the price is you 
either write typchecking code or let the error propagate into the 
function or method. I hope type annotations in py3k will allow for 
something like constraints in C# where you can tell the caller right 
away she's doing something wrong.

greetings
  Paul

BTW: are type annotations to be backported to 2.x?




More information about the Python-list mailing list