Remove redundant __nonzero__ methods
authorRémi Cardona <remi.cardona@logilab.fr>
Thu, 24 Apr 2014 12:28:46 +0200
changeset 9780 8e687be43d84
parent 9779 3f1685ac2f16
child 9781 f5728fc3c486
Remove redundant __nonzero__ methods From https://docs.python.org/2/reference/datamodel.html#specialnames : When this method is not defined, __len__() is called, if it is defined, and the object is considered true if its result is nonzero. Also helpful for an eventual migration to py3k, as __nonzero__ has been replaced with __bool__, which also defaults to looking at __len__ if undefined.
rset.py
utils.py
--- a/rset.py	Fri May 23 18:12:47 2014 +0200
+++ b/rset.py	Thu Apr 24 12:28:46 2014 +0200
@@ -112,9 +112,6 @@
         """returns the result set's size"""
         return self.rowcount
 
-    def __nonzero__(self):
-        return self.rowcount
-
     def __getitem__(self, i):
         """returns the ith element of the result set"""
         return self.rows[i] #ResultSetRow(self.rows[i])
--- a/utils.py	Fri May 23 18:12:47 2014 +0200
+++ b/utils.py	Thu Apr 24 12:28:46 2014 +0200
@@ -169,8 +169,6 @@
             id(self), self._item, self._size)
     def __len__(self):
         return self._size
-    def __nonzero__(self):
-        return self._size
     def __iter__(self):
         return repeat(self._item, self._size)
     def __getitem__(self, index):