def _make_cmp(set_op, doc):
def comparer(self, that):
if isinstance(that, SortedSet):
return set_op(self._set, that._set)
elif isinstance(that, Set):
return set_op(self._set, that)
else:
raise TypeError('can only compare to a Set')
comparer.__name__ = '__{0}__'.format(set_op.__name__)
comparer.__doc__ = 'Return True if and only if ' + doc
return comparer
评论列表
文章目录