Message414830
What about mix-ins or abstract base classes?
class VecMixin:
def length(self):
return math.hypot(*self)
class Vec2D(NamedTuple, VecMixin):
x: float
y: float
class Vec3D(NamedTuple, VecMixin):
x: float
y: float
z: float
Currently you need to use the following trick to get a similar result:
class Vec2D(NamedTuple):
x: float
y: float
class Vec2D(Vec2D, VecMixin):
pass |
|
| Date |
User |
Action |
Args |
| 2022-03-10 08:17:42 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, gvanrossum, rhettinger, eric.smith, python-dev, graingert, levkivskyi, dlukes, JelleZijlstra, FHTMitchell, Steven Silvester, sobolevn, kj, AlexWaygood, juliusgeo |
| 2022-03-10 08:17:42 | serhiy.storchaka | set | messageid: <1646900262.03.0.469523926882.issue43923@roundup.psfhosted.org> |
| 2022-03-10 08:17:42 | serhiy.storchaka | link | issue43923 messages |
| 2022-03-10 08:17:41 | serhiy.storchaka | create | |
|