The code below is for constructing a linked list.
I created an instance of Node named a, and gave it an item 'hello', and created an instance of a Node named b, and then gave it a value 'world'
, and then did a.setOther(b)
;
When I then type a.getOther()
I don't get 'world', but I get <__main__.Node at 0x140ae7fafd0>
.
Is this like a pointer, giving the location of the data on my disk? If so, how do I then display the data from this location?
class Node(object):
def __init__(self, item, other = None):
self.item = item
self.other = other
def getItem(self):
return self.item
def getOther(self):
return self.other
def setItem(self, item):
self.item = item
def setOther(self, other):
self.other = other