chiark
/
gitweb
/
~ian
/
secnet.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
59f471e
)
ipaddrset: Define __bool__ and make __nonzero__ an alias
author
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Fri, 18 Oct 2019 20:34:13 +0000
(21:34 +0100)
committer
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Thu, 24 Oct 2019 18:16:16 +0000
(19:16 +0100)
Python3 calls __bool_. Python2 calls __nonzero__.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
ipaddrset.py
patch
|
blob
|
history
diff --git
a/ipaddrset.py
b/ipaddrset.py
index 54869580840aa4fa9d53fbbd27164cbaa98f9cd7..84c7dcacdd66aff139f06d05331df374d3a64778 100644
(file)
--- a/
ipaddrset.py
+++ b/
ipaddrset.py
@@
-68,11
+68,12
@@
class IPAddressSet:
self._v[a.version].append(a)
# enquirers including standard comparisons
- def __
nonzero
__(self):
+ def __
bool
__(self):
for v in _vsns:
if self._v[v]:
return True
return False
+ __nonzero__=__bool__ # for python2
def __eq__(self,other):
for v in _vsns: