In a case like:
class Foo(object):
def __init(self, x):
self.var = x
def loop(self):
# [yield params]
result = self.do_sth(params)
def do_sth(self, params):
if self.var is not None:
bar(params)
if self.var > 1:
do_other_bar(params)
if __name__ == '__main__':
foo = Foo(2)
In my project i have a class consisting of a lot of methods, so I want to move the do_sth
method outside (e.g. into another module):
# mymodule.py
def do_sth_external(params, var):
if var is not None:
bar()
if var > 1:
do_other_bar()
from mymodule import do_sth_external
class Foo(object):
def __init(x):
self.var = x
def loop():
# [yield params]
result = do_sth_external(params, self.var)
if __name__ == '__main__':
foo = Foo(2)
what other ways are there to break down a huge class?
Edit: whatever reason someone thought this question was opinion based. It is asking for best practices...