Is there any way you can define a function that can add,at some later point in the program, new attributes to an already existing __init__ method? For example, below I created a Class for a Family Tree. Each instance would create a root.
class FamilyTree:
def __init__(self,rootObj):
self.key = rootObj
I want each new root instance to have the ability to have a specific number of children attributes: For example:
self.child1 = 'B'
self.child2 = 'C'
self.child3 = 'D'
Since every new root instance can have various number of children, how can I variably add new attributes to the __init__ method?
__init__method, you are adding to the class instance. Consider rewording your question slightly to clear up this ambiguity.