I need to define a custom data structure (say, Exp) which can have fields as same data structure (i.e., Exp) but very confused what to use...
I'm using NamedTuple in Python3 but when defining the field of type same structure, get Errors.
from typing import NamedTuple
class Expression(NamedTuple):
left: Expression
right: Expression
operator: str
exp = Expression(None, None, "AS")
print(exp)
this generates error as follows:
Traceback (most recent call last):
File "expression.py", line 3, in <module>
class Expression(NamedTuple):
File "expression.py", line 4, in Expression
left: Expression
NameError: name 'Expression' is not defined