Use a package. Place the functions in a separate module, without using a class.
Within the statistics folder on your computer define 2 modules:
helpers.py
where you define the helper functions.
__init__.py
where you write the bulk of your code.
You may rename the helpers
module, if you can come up with a better name for the group of functions you define within it. However, the __init__
module of a package is special. When the package is imported, the __init__
module is given the package name and evaluated.
To apply your example:
#statistics\helpers.py
def do_statistics1(params):
pass
def do_statistics2(params):
pass
# Rest of module omitted
#statistics\__init__.py
# Relative import
from . import helpers
# Get function using getattr()
do_statistics1 = getattr(helpers, "do_statistics1")
# Get function using dot notation
do_statistics2 = helpers.do_statistics2
# Rest of module omitted
Be sure to test the package by importing it. Relative imports do not work when evaluating a module within a package.
In conclusion, you can get attributes from a module just like you can from a class.