So I hear that modules are very pythonic and I structure my code with modules a lot and avoid classes.
But now I'm writing a module Formula
that has a lot of the same functionality as the module Car
. How should I handle that?
- Duplicate code in both modules?
- Convert to classes?
- Refactor code to add a third, parent module
Vehicle
and import methods and variables that I need?
The third looks good, the only downside that I see is that there are some variables that are specific to a module (e.g. top_speed), but the functions in the parent module Vehicle need to access those specific variables.