是否可以生成继承自基类的namedtuple
?在
我想要的是Circle
和Rectangle
是namedtuple
,并且是从一个公共基类('Shape')继承的:
from collections import namedtuple
class Shape:
def addToScene(self, scene):
...
Circle=namedtuple('Circle', 'x y radius')
Rectangle=namedtuple('Rectangle', 'x1 y1 x2 y2')
我该怎么做?在
你可以试试这个:
(您应该考虑将^{} 添加到所有三个类中,以节省内存和更快的查找速度。)
相关问题 更多 >
编程相关推荐