ucphhpc / docker-migrid

Containerized MiG
GNU General Public License v2.0
3 stars 7 forks source link

Define equality checks of objects via "rich comparison" methods #4

Closed rasmunk closed 4 years ago

rasmunk commented 5 years ago

https://github.com/rasmunk/docker-migrid/blob/9b8b092f1eb1d7117088a19fe8e0a48bd740fcd4/mig/shared/pattern.py#L16

When you wan't to do an equality check between instances of the same object type, you should implement it via the so called "rich comparison" methods as per https://docs.python.org/2/reference/datamodel.html#object.__eq__

An example can be seen here https://devinpractice.com/2016/11/29/python-objects-comparison/

This then allows for the direct comparisons checks, e.g:

(self.__eq__) pattern1 == pattern2

(self.__ne__) pattern1 != pattern2

rasmunk commented 4 years ago

As per the refactor this is no longer an issue