【发布时间】:2012-12-11 06:38:36
【问题描述】:
我想从 Base 类继承 collection arg。怎么样?
class Base(object):
def __init__(self, collection=None, classname=None):
self.__collection__ = collection or self.__class__.__name__
class Thing(Base):
def __init__(self, **kwargs):
super(Thing, self).__init__()
self.__dict__.update(kwargs)
t = Thing(collection='foobar')
t.__collection__
>>> 'Thing'
:(
【问题讨论】:
-
别忘了接受答案。
标签: python class inheritance