美文网首页
python 类支持比较

python 类支持比较

作者: SkTj | 来源:发表于2019-12-04 11:06 被阅读0次

    class House:
    def eq(self, other):
    pass
    def lt(self, other):
    pass
    # Methods created by @total_ordering
    le = lambda self, other: self < other or self == other
    gt = lambda self, other: not (self < other or self == other)
    ge = lambda self, other: not (self < other)
    ne = lambda self, other: not self == other

    相关文章

      网友评论

          本文标题:python 类支持比较

          本文链接:https://www.haomeiwen.com/subject/csbcpctx.html