raymond wrote:
There were a couple of threads on comp.lang.py with headings like "isinstance considered harmful". The conclusion was that most cases should have been coded some other way. The legitimate uses included implementing multiple dispatch (supporting calls with type differentiated signatures) , factory functions, decorator pattern (which needs to know if the object was previously decorated), and the composite pattern (which needs to know if it is dealing with an atom or a composite).
since when is comp.lang.py is an authority on anything?
Here are some of the ideas for conversion:
if type(x) is int --> if x==int(x) # 3L would be passable
are these supposed to be equivalent, for any kind of x? what Python version are you using? </F>