paul schrieb: > Bruno Desthuilliers schrieb: >> [EMAIL PROTECTED] 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.
This is a dead horse beaten into the ground, full way through to china. If you want typechecking - use a statically checked language. After all, if you like to constrain yourself to certain types - why not benefit from a compiler then? I for once prefer to be able to pass object that behaves like e.g. a file - think StringIO - to something taking a file, instead of introducing a interface-maze like the java.io-hierarchy to capture each possible thinkable aspect of file IO in a separate interface - and then hoping that the third party library was careful enough to only require what is really needed. Diez -- http://mail.python.org/mailman/listinfo/python-list