def as_scalar(value):
"""Convert value to a scalar. If a single element Attrs() object is passed
the value of the single attribute will be returned."""
if isinstance(value, Attrs):
assert len(value) == 1
return value[0][1]
else:
return value
评论列表
文章目录