Fixed a logical mistake in EmailAddress.__ne__() (not used),
authorPascal Volk <neverseen@users.sourceforge.net>
Tue, 18 Aug 2009 05:08:51 +0000
changeset 116 949c5db6447a
parent 115 21f264a88ab2
child 117 c96b5768c76d
Fixed a logical mistake in EmailAddress.__ne__() (not used), small code cleanups.
VirtualMailManager/EmailAddress.py
--- a/VirtualMailManager/EmailAddress.py	Tue Aug 18 03:00:00 2009 +0000
+++ b/VirtualMailManager/EmailAddress.py	Tue Aug 18 05:08:51 2009 +0000
@@ -20,20 +20,18 @@
         self._localpart = None
         self._domainname = None
         self.__chkAddress(address)
-    
+
     def __eq__(self, other):
-        if hasattr(other, '_localpart') and hasattr(other, '_domainname'):
+        if isinstance(other, self.__class__):
             return self._localpart == other._localpart\
                     and self._domainname == other._domainname
-        else:
-            return NotImplemented
+        return NotImplemented
 
     def __ne__(self, other):
-        if hasattr(other, '_localpart') and hasattr(other, '_domainname'):
-            return not self._localpart == other._localpart\
-                    and self._domainname == other._domainname
-        else:
-            return NotImplemented
+        if isinstance(other, self.__class__):
+            return self._localpart != other._localpart\
+                    or self._domainname != other._domainname
+        return NotImplemented
 
     def __repr__(self):
         return "EmailAddress('%s@%s')" % (self._localpart, self._domainname)
@@ -60,7 +58,7 @@
 
     def __chkLocalpart(self, localpart):
         """Validates the local part of an e-mail address.
-        
+
         Keyword arguments:
         localpart -- of the e-mail address that should be validated (str)
         """