是什么any = lambda v: v
意思?似乎v
只有v
它自己。
class Object(object):
"""Common base class supporting automatic kwargs->attributes handling,
and cloning."""
attrs = ()
def __init__(self, *args, **kwargs):
any = lambda v: v
for name, type_ in self.attrs:
value = kwargs.get(name)
if value is not None:
setattr(self, name, (type_ or any)(value))
else:
try:
getattr(self, name)
except AttributeError:
setattr(self, name, None)