Is the following class definition a good design?
class Myclass:
def __init__(self,num1,num2):
self.complicated_tree = __class__.object_creator(num1,num2)
@classmethod
def tree_creator(cls,num1,num2):
return num1+num2 #in practice, this functions would be really long
#and would return a whole tree of numbers
#my tree doesn't need all the standard traversing etc. methods, just very few
#special ones
def specialized_method1(self):
pass
def specialized_method2(self):
pass
I'm a beginner in Python and so far every class __init__ method arguments were identical to the object attributes. In this case, this is not true anymore, because this class shall contain objects that first need to be constructed in a complicated way: a special type of tree that I first need to generate in 20 lines of code using num1 and num2.
Is this defining such a class good design/practice? Or should I generate the whole tree outside of the class, so that the tree's __init __ method is
def __init__(self,tree):
self.tree = tree
and the tree_creator function is a separate function outside the class?