| 125 | |
| 126 | # test and demonstrate ability to override methods |
| 127 | class Point(namedtuple('Point', 'x y')): |
| 128 | @property |
| 129 | def hypot(self): |
| 130 | return (self.x ** 2 + self.y ** 2) ** 0.5 |
| 131 | def __str__(self): |
| 132 | return 'Point: x=%6.3f y=%6.3f hypot=%6.3f' % (self.x, self.y, self.hypot) |
| 133 | |
| 134 | for p in Point(3,4), Point(14,5), Point(9./7,6): |
| 135 | print p |
no test coverage detected