我正在使用以下代码收集实例:
class Hand():
    instances = []
    def __init__(self):
        Hand.instances.append(self)
        self.value = 5
    def do_something(self, a):
        self.value = self.value * a
class Foo():
    def __init__(self):
        pass
    def insty(self):
        self.hand1 = Hand()
        self.hand2 = Hand()
foo = Foo()
foo.insty()
print Hand.instances
for hand in Hand.instances:
    print "how do I print the instance name?"
最后一行只是一种学习如何访问实例名称的方法,因此我可以按顺序在每个实例上调用“do_something”方法。
如何访问 Hand 的每个实例的实例名称?