Mr.Rech wrote: > Hi all, > I've read some thread about isinstance(), why it is considered harmful > and how you can achieve the same results using a coding style that > doesn't break polymorphism etc... Since I'm trying to improve my Python > knowledge, and I'm going to design a class hierarchy from scratch, I'd > like to have some feedback about this from those of you much more > experienced than me in OOP. [snip] > Any better way to write this method? Any suggestion?
It's really impossible to tell what's good Python code based on details like this. isinstance() wouldn't be in Python if you weren't supposed to use it, but you need to understand when you should limit your functions to work with a specific kind of data, and when you should try to be broader. This is a design decision that will influence the usability and maintainability of your code. We can't help you figure out how to make such trade-offs based on your implementation of __eq__. -- http://mail.python.org/mailman/listinfo/python-list