Create class with equal operator



    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
    • Playground
    • Snippets
    • Cookbooks
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.