python new instance not updating variable

  instance, oop, python, python-3.x

I’m trying to learn python with some data-structure. I’m trying to create a binary tree.

So I’ve created a node like:

class Node(object):
    def __init__(self,value,left,right):
        self.value = value
        self.left = left
        self.right = right

Then I’ve created a tree like:

class Tree(object):
    def __init__(self):
        self.node = None

    def insert(self,node,element):
        if node == None:
            node = Node(element,None,None)
        elif element <= node.value:
            self.insert(node.left, element)
            self.insert(node.right, element)

When I’m trying to insert element to the tree, it doesn’t work. There is a stack call for that insert and the node==None is hitting and new Node is being created. But the Tree is not updating.

Source: Python-3x Questions