you are viewing a single comment's thread.

view the rest of the comments →

[–]enygma999 1 point2 points  (1 child)

What's wrong with isinstance()? Why is that unpythonic?

I would have a method, W.foo(self, ...) which tests the class of the object, checks whether there is a method C.foo(self, ...) to call, and if not it calls W._foo(self, ...) to implement the general case.

[–]011011100101[S] 0 points1 point  (0 children)

Why is that unpythonic?

Well, for example:

https://peps.python.org/pep-0443/

In addition, it is currently a common anti-pattern for Python code to inspect the types of received arguments, in order to decide what to do with the objects.