Choose: class with static methods or module with functions

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Thu Apr 16 18:55:40 CEST 2009


Ravi:
> Which is a better approach.
> My personal view is that I should create a module with functions.

When in doubt, use the simplest solution that works well enough. In
this case, module functions are simple and probably enough.

But there can be a situation where you want to keep functions even
closer, for example because in a module you have two classes and two
groups of functions related to each class. In such situation
staticmethods seem better.

Bye,
bearophile



More information about the Python-list mailing list