Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Can the scope of a module be expanded ?
#1
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)
Quote
#2
from optimizer import optimizer
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Solving a scope issue profconn1 4 234 Nov-01-2019, 07:46 PM
Last Post: profconn1
  Namespace and scope difference Uchikago 9 534 Jul-03-2019, 03:36 PM
Last Post: Uchikago
  what is scope for python? samexpert 2 240 Jun-24-2019, 01:03 PM
Last Post: metulburr
  main function scope issues wak_stephanie 1 638 Aug-29-2018, 02:53 AM
Last Post: Larz60+
  Help in understanding scope of dictionaries and lists passed to recursive functions barles 2 729 Aug-11-2018, 06:45 PM
Last Post: barles
  Variable Scope for Scripts QueenSvetlana 6 1,256 Dec-01-2017, 08:54 PM
Last Post: snippsat
  Problem With Scope Of A Variable Saif133 5 2,236 Jan-05-2017, 05:18 PM
Last Post: snippsat
  List out of scope? kjorin 13 4,304 Nov-08-2016, 04:25 AM
Last Post: kjorin

Forum Jump:


Users browsing this thread: 1 Guest(s)