MCPcopy Create free account
hub / github.com/ActiveState/code / Point

Class Point

recipes/Python/578918_Yet_Another_NamedTuple/recipe-578918.py:187–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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)

Callers 2

recipe-578918.pyFile · 0.70
recipe-578884.pyFile · 0.50

Calls 2

namedtupleFunction · 0.70
classmethodFunction · 0.50

Tested by

no test coverage detected