I want to define own tree-like class. I've written code like this:
class forest:
class tree:
def __init__(self):
self.var_a = []
self.var_b = []
#Or something as simple
def mk(self,something):
#Some instructions
self.a = tree()
b_var = self.a.mk(a_var)
self.b = tree()
c_var = self.a.mk(b_var)
#Some instructions
return ret
#Some code for class forest
Well tree() doesn't work.
NameError: global name 'tree' is not defined
The error for self.tree():
AttributeError: 'tree' object has no attribute 'tree'
I do not know how (or if) to use self.__init__ or self.__new__ in this context.
The question
It is possible to use recursive class in Python3? How does the code for this look like?
forest.treesince thetreeclass is inside theforestclass.