So Python doesn't really do this. I have a class called tree, it's a binary tree type.
class Tree(object):
    def __init__(self):
        self.left = None
        self.right = None
        self.data = None
    def filler(self, lista, tree):
        tree = Tree()
        nr = len(lista)
        nr //= 2
        if len(lista) == 0:
            return
        if len(lista) == 1:
            tree.data = lista[0]
            return
        tree.data = lista[nr]
        self.filler(lista[:nr], tree.left)
        self.filler(lista[nr:], tree.right)
Function filler() transforms a list into a binary tree. I try calling it like this:
tr = Tree()
tr2 = Tree()
l = self.ctrler.Backtrack(self.ctrler.tsk, 0) -- some list
tr.filler(l, tr2)
print(tr2.data)
The result is None. filler() doesn't do anything. Can I do anything about this? Can I pass the tr2 object by reference? How can I transform a list into a binary tree if I can't pass it by reference?
Traceback without the instatiation of tree in the filler:
Traceback (most recent call last):
  File "D:/Projects/Python/AIExcavator/src/ui.py", line 75, in <module>
    uier.inter()
  File "D:/Projects/Python/AIExcavator/src/ui.py", line 63, in inter
    tr.filler(l, tr2)
  File "D:\Projects\Python\AIExcavator\src\Backtracking.py", line 79, in filler
    self.filler(lista[:nr], tree.left)
  File "D:\Projects\Python\AIExcavator\src\Backtracking.py", line 78, in filler
    tree.data = lista[nr]
AttributeError: 'NoneType' object has no attribute 'data'
 
     
     
     
    