Using module-level functions inside class method python

What i want to do is to generate from given images new ones.

I have created transformation functions:

def trans_func_1(image,param1,param2):
    #do some transformation

def trans_func_2(image,param1,param2):
    #do some transformation

All functions operates on image level.

Then I have a big function which is called generate_image function, which takes as arguments a path to the folder with images, parameters for the written above functions and applies transformation functions to the images.

My idea is to define transformation functions as module-level functions and for the big functions create a class, that will look this

class ImageGeneration:


def __init__(self,path,trans_param1,trans_param2):
    
    self.path = path
    self.trans_param1 = trans_param1
    self.trans_param2 = trans_param2
    ...

def image_generation(self):
    for image in self.path:
        
        for i in self.trans_param1:
            img = trans_func_1(image,i)
            write_img(img)  

        for i in self.trans_param2:
            img = trans_func_2(image,i)
            write_img(img)
           

My question is: is it a good practice to use module-level functions inside a class? Or is it better to define them as @staticmethod


For your case, it is completely fine to let the module-level function instead of adding all of them to the class as static.

The class is responsible for handling the parameters and retrieving a generated image. The transformations functions are specific to their own transformation, thus not being necessary to add them to the handler.

This also allows you to have much better modularity. Depending on how many transformations you want to create, you may have a 500 line class where only 40 lines are handled and the rest are specific transformations. Separating each transformation into its own file (or separating them by scopes) would be my preferred way to go.