delegate '__nonzero__' to '__bool__' for py2/py3 compatibility in one source. #1350

This commit is contained in:
Takayuki Shimizukawa
2014-05-01 20:14:19 +09:00
parent 956d6286bf
commit 75e22ba522
3 changed files with 6 additions and 3 deletions

View File

@@ -246,7 +246,7 @@ class Element(object):
def __len__(self):
return len(self._children)
def __nonzero__(self):
def __bool__(self):
import warnings
warnings.warn(
"The behavior of this method will change in future versions. "
@@ -254,6 +254,7 @@ class Element(object):
FutureWarning
)
return len(self._children) != 0 # emulate old behaviour
__nonzero__ = __bool__ # for python2 compatibility
##
# Returns the given subelement.