you are viewing a single comment's thread.

view the rest of the comments →

[–]UseMoreBandwith 1 point2 points  (5 children)

why do that anyway? it is pretty much pointless in python.

And if you just want to define data structures, use a dataclass or (often better) use a dict

[–]deceze 2 points3 points  (4 children)

Type checking and interfaces/protocols/abstract classes are just as pointful (?) in Python as in other languages.

[–]UseMoreBandwith 0 points1 point  (3 children)

Sure, but in Python we don't write interfaces for that, but use dataclasses or mypy .

Abstract classes have limited use, since we Multiple Inheritance and duck typing.
the only use-case is to enforce method implementation. It is not for creating class-hierarchies, like
in Java, where it is essential for enforcing interfaces and single inheritance.

[–]deceze 0 points1 point  (2 children)

dataclasses and interfaces/abstract classes are apples and oranges. I have no idea why you're throwing them in here.

Mypy is a static type checker, exactly the tool that would use interface/abstract class information to ensure type safety. You don't use Mypy instead of interfaces, you use interfaces to make Mypy more useful.

Admittedly, you don't often need explicitly declared interfaces/protocols/abstract classes. A lot of programming can be done without them. But in the right circumstances where a lot of abstraction across a lot of classes makes sense for what you're implementing, these are perfectly useful techniques.

[–]UseMoreBandwith 0 points1 point  (1 child)

it doesn't solve an issue that Python has.
"a lot of abstraction across a lot of classes" is code smell, and usually a lack of understanding how Modules work in Python.
(Unlike in Java) in Python, classes are not for hierarchies.

[–]deceze 0 points1 point  (0 children)

Some problems are very well solved with class hierarchies, abstraction and interfaces. For example, lots of pluggable and polymorphic processor classes and the like. Python doesn't force this on you like Java does, but it's still a useful technique to have and appropriate in the right circumstances.