だから私はと呼ばれるクラスを持ってい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))
次のように、このクラスのオブジェクトのリストを出力したいと思います。
x = [Vertex(1), Vertex(2)]
print x
しかし、次のような出力が表示されます。
[<__main__.Vertex instance at 0xb76ed84c>, <__main__.Vertex instance at 0xb76ed86c>]
Vertex.label
実際には、各オブジェクトの値を出力したかったのです。それを行う方法はありますか?