From 9b219289a6a740df005b107e991a62899aae6a7b Mon Sep 17 00:00:00 2001 From: Kyle Fuller Date: Tue, 28 Feb 2012 18:08:57 +0000 Subject: [PATCH] Python: Override __eq__ to allow comparison of strings Closes #135 --- modules/modpython/znc.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/modules/modpython/znc.py b/modules/modpython/znc.py index 04b97411..eb56b9e6 100644 --- a/modules/modpython/znc.py +++ b/modules/modpython/znc.py @@ -661,3 +661,16 @@ class ModulesIter(collections.Iterator): self._cmod.plusplus() return module CModules.__iter__ = lambda cmod: ModulesIter(CModulesIter(cmod)) + + +def str_eq(self, other): + if str(other) == str(self): + return True + + return id(self) == id(other) + +CChan.__eq__ = str_eq +CNick.__eq__ = str_eq +CUser.__eq__ = str_eq +CIRCNetwork.__eq__ = str_eq +CPyRetString.__eq__ = str_eq