| 185 | |
| 186 | # test and demonstrate ability to override methods |
| 187 | class Point(namedtuple('Point', 'x y')): |
| 188 | @property |
| 189 | def hypot(self): |
| 190 | return (self.x ** 2 + self.y ** 2) ** 0.5 |
| 191 | def __str__(self): |
| 192 | return 'Point: x=%6.3f y=%6.3f hypot=%6.3f' % (self.x, self.y, self.hypot) |
| 193 | |
| 194 | for p in Point(3,4), Point(14,5), Point(9./7,6): |
| 195 | print (p) |
no test coverage detected