Chris Barker <chris.bar...@noaa.gov> wrote: > Sure -- but I'm afraid that there will be a lot of code that does an > isinstance() check where it it absolutely unnecessary. If you really need > to know if something is a sequence or a mapping, I suppose it's required, > but how often is that?
I must say I don't understand the purpose of Java-like interfaces in Python. It is better to ask forgiveness than ask permission. If an object does not have the required attributes we sooner or later get an AttributeError. Is doing an isinstance() check and then raising TypeError inherently better? In both cases we get an error that unit tests should detect. I might do sanity checks on the input data if it is required to ensure correct output. But I never do this to ensure that objects have all the attributes they should. If they don't I prefer my program to die with an unhandled AttributeError. Sturla _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion