diff --git a/autoclass/autoeq_.py b/autoclass/autoeq_.py index edb49e4..10f7708 100644 --- a/autoclass/autoeq_.py +++ b/autoclass/autoeq_.py @@ -157,10 +157,14 @@ def __eq__(self, other): """ Generated by @autoeq. Relies on the hardcoded list of field names and "getattr" (object) for the value. """ - for att_name in selected_names: - if getattr(self, att_name) != getattr(other, att_name): - return False - return True + try: + for att_name in selected_names: + if getattr(self, att_name) != getattr(other, att_name): + return False + except AttributeError: + return False + else: + return True return __eq__