pyyaml doc でこのコードを参照してください。なぜ"Dice(%s,%s)" % self
機能するのですか? varは 2 つ%s
しかありself
ません。
>>> class Dice(tuple):
... def __new__(cls, a, b):
... return tuple.__new__(cls, [a, b])
... def __repr__(self):
... return "Dice(%s,%s)" % self
>>> print Dice(3,6)
Dice(3,6)
http://pyyaml.org/wiki/PyYAMLDocumentation#Constructorsrepresentersresolvers