Python - Is it okay to pass self to an external function -
i have class, a, inherited bunch of other classes. of these have few functions similar , nice have functions defined somewhere else , called classes need them. functions call functions defined in super class.
class a(): def imp_func(*args): # called child class functions class b(a): def common_func(self): # stuff self.imp_func(*args)
so have created helper functions take self object
argument , can call imp_func
inside helper functions.
def helper_func(obj, some_args): # common stuff obj.imp_func(*args) class b(a): def common_func(self): # unique stuff helper_func(self, some_args)
this solves problem.
but should doing this? pythonic?
there no problem whatsoever. instances of self
passed functions (and methods of other classes) time.
Comments
Post a Comment