Cleanup named tuple subclassing example.
diff --git a/Lib/collections.py b/Lib/collections.py
index 51184a4..c19821b 100644
--- a/Lib/collections.py
+++ b/Lib/collections.py
@@ -120,10 +120,11 @@
@property
def hypot(self):
return (self.x ** 2 + self.y ** 2) ** 0.5
- def __repr__(self):
- return 'Point(x=%.3f, y=%.3f, hypot=%.3f)' % (self.x, self.y, self.hypot)
+ def __str__(self):
+ return 'Point: x=%6.3f y=%6.3f hypot=%6.3f' % (self.x, self.y, self.hypot)
- print Point(3, 4),'\n', Point(2, 5), '\n', Point(9./7, 6)
+ for p in Point(3,4), Point(14,5), Point(9./7,6):
+ print p
class Point(namedtuple('Point', 'x y')):
'Point class with optimized _make() and _replace() without error-checking'