Python Forum

Full Version: Can the scope of a module be expanded ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a module named optimizer.py which has a class optimizer. The class contains 2 static member functions. Optimizer.py looks something like this:
class optimizer:
    @staticmethod
    def gradientDescentOptimizer(input,mappings,net:nn.nn,alpha=0.001,lamb=None, epoch=100,print_at=5,prnt=True):
        #Code

    @staticmethod
    def SGDOptimizer(input,mappings,net:nn.nn,mini_batch_size=64,alpha=0.001,lamb=None, epoch=5,print_at=5,prnt=True):
        #code
To access the functions in other modules, I need to follow this syntax:
import optimizer

x = optimizer.optimizer.functionName(arguments)
I was wondering if there is a way to expand the scope of the optimizer class so that the function can be accessed by referring to the optimizer class just once, like this :
import optimizer

x = optimizer.functionName(arguments)
from optimizer import optimizer