So I have a class, called Vertex
.
class Vertex:
'''
This class is the vertex class. It represents a vertex.
'''
def __init__(self, label):
self.label = label
self.neighbours = []
def __str__(self):
return("Vertex "+str(self.label)+":"+str(self.neighbours))
I want to print a list of objects of this class, like this:
x = [Vertex(1), Vertex(2)]
print x
but it shows me output like this:
[<__main__.Vertex instance at 0xb76ed84c>, <__main__.Vertex instance at 0xb76ed86c>]
Actually, I wanted to print the value of Vertex.label
for each object.
Is there any way to do it?