Create class with equal operator

    0

    25

    Python public recipes

    Shortcut: class.new_with_eq

    class ClassName:
      def __init__(self, attribute):
        self.attribute = attribute
      def __eq__(self, other):
        if isinstance(other, ClassName):
          return self.attribute == other.attribute
        return False
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.