Create class with equal operator

    0

    35

    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
    Legal
    • 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.