I would like to make a python module that can work both as standalone (so with a __main__
that has positional parameters for the options) and as regular module (so I can import the class(es) in the module for a pure code-based approach.
Is there a best practice to do so; in a way that neither the standalone nor the import action is affecting negatively the module?
I have in mind a simple module with one class, which contain different functions; and then at the bottom I have the
if __name__ == '__main__':
# collect parameters and run a function in the class
Which is used if I want to call my module as standalone.