在Odoo 9.0类MetaField
方法__init__()
中,为什么dir(cls)
结果包含“参数”?
class MetaField(type):
# ...
def __init__(cls, name, bases, attrs):
# ...
for attr in dir(cls):
if attr.startswith('_column_'):
cls.column_attrs.append((attr[8:], attr))
elif attr.startswith('_related_'):
cls.related_attrs.append((attr[9:], attr))
elif attr.startswith('_description_'):
cls.description_attrs.append((attr[13:], attr))
dir(cls)
结果:
[...'_setup_related_full', '_slots', 'args', 'automatic', 'base_field'...]
我只能在Field.args
中找到__init__()
声明,它会让args
进入dir()
吗?
class Field(object):
# ...
def __init__(self, string=None, **kwargs):
kwargs['string'] = string
args = {key: val for key, val in kwargs.iteritems() if val is not None}
self.args = args or EMPTY_DICT
self._setup_done = None