I am not sure how to return the object name, instead of its memory address. For instance:
class BSTNode:
def __init__(self, data=None, left=None, right=None):
self.data, self.left, self.right = data, left, right
def search_bst(tree, key):
return (tree if not tree or tree.data == key
else search_bst(tree.left, key)
if key < tree.data else search_bst(tree.right, key))
I would like it to give me the Node name, such as "A", "B", "C" in the BST, instead of <__main__.BSTNode object at 0x7f64b9eedf28>
etc.
If there is no easy way around it, I want to know if we can use the memory address to find the corresponding object name, along with other properties of the node.