Lets say i have something like this:
This is file tree.py:
class leaf():
def green():
x = 100
This is file view.py:
from tree import leaf.green
g = green()
print g.x
How do i get the variable form subclass green
I know for class its just:
This is file tree.py:
class leaf():
x = 100
This is file view.py:
from tree import leaf
class view():
g = leaf()
print g.x
I understand how to do it if both classes are in the same file. But i dont understand in two seprate files.
Thanks,
John
I think the root of your problem is that you need to learn more about how classes in Python work. Fortunately, the tutorial in the Python docs has a section on classes.
If that doesn’t help, going through something like Learn Python the Hard Way and doing the exercises can be immensely helpful.