【发布时间】:2012-04-12 07:25:49
【问题描述】:
class A (object):
keywords = ('one', 'two', 'three')
class B (A):
keywords = A.keywords + ('four', 'five', 'six')
有什么方法可以将A.keywords 更改为<thing B derives from>.keywords,有点像super(),但之前是__init__/self?我不喜欢在定义中重复类名。
用法:
>>> A.keywords
('one', 'two', 'three')
>>> B.keywords
('one', 'two', 'three', 'four', 'five', 'six')
【问题讨论】: