summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorJack Diederich <jackdied@gmail.com>2006-11-28 19:15:13 (GMT)
committerJack Diederich <jackdied@gmail.com>2006-11-28 19:15:13 (GMT)
commit4dafcc4ece09c2a60473bb109513de4e7d2c2b11 (patch)
tree32be8af9dd16e1ea407bf008c92d62f7cd7539bd /Doc
parentdfc9d4f7aa38a3961847c034532e39f05a569f54 (diff)
downloadcpython-4dafcc4ece09c2a60473bb109513de4e7d2c2b11.zip
cpython-4dafcc4ece09c2a60473bb109513de4e7d2c2b11.tar.gz
cpython-4dafcc4ece09c2a60473bb109513de4e7d2c2b11.tar.bz2
- patch #1600346 submitted by Tomer Filiba
- Renamed nb_nonzero slots to nb_bool - Renamed __nonzero__ methods to __bool__ - update core, lib, docs, and tests to match
Diffstat (limited to 'Doc')
-rw-r--r--Doc/lib/liboperator.tex2
-rw-r--r--Doc/lib/libstdtypes.tex2
-rw-r--r--Doc/lib/libtimeit.tex16
-rw-r--r--Doc/lib/libwinreg.tex2
-rw-r--r--Doc/lib/libxmlrpclib.tex2
-rw-r--r--Doc/ref/ref3.tex14
6 files changed, 19 insertions, 19 deletions
diff --git a/Doc/lib/liboperator.tex b/Doc/lib/liboperator.tex
index 5ba3209..867c2ab 100644
--- a/Doc/lib/liboperator.tex
+++ b/Doc/lib/liboperator.tex
@@ -55,7 +55,7 @@ and support truth tests, identity tests, and boolean operations:
Return the outcome of \keyword{not} \var{o}. (Note that there is no
\method{__not__()} method for object instances; only the interpreter
core defines this operation. The result is affected by the
-\method{__nonzero__()} and \method{__len__()} methods.)
+\method{__bool__()} and \method{__len__()} methods.)
\end{funcdesc}
\begin{funcdesc}{truth}{o}
diff --git a/Doc/lib/libstdtypes.tex b/Doc/lib/libstdtypes.tex
index d5409e0..17e377b 100644
--- a/Doc/lib/libstdtypes.tex
+++ b/Doc/lib/libstdtypes.tex
@@ -51,7 +51,7 @@ The following values are considered false:
\item any empty mapping, for example, \code{\{\}}.
\item instances of user-defined classes, if the class defines a
- \method{__nonzero__()} or \method{__len__()} method, when that
+ \method{__bool__()} or \method{__len__()} method, when that
method returns the integer zero or \class{bool} value
\code{False}.\footnote{Additional
information on these special methods may be found in the
diff --git a/Doc/lib/libtimeit.tex b/Doc/lib/libtimeit.tex
index 1c4e05b..2629439 100644
--- a/Doc/lib/libtimeit.tex
+++ b/Doc/lib/libtimeit.tex
@@ -162,13 +162,13 @@ the module interface) that compare the cost of using
missing and present object attributes.
\begin{verbatim}
-% timeit.py 'try:' ' str.__nonzero__' 'except AttributeError:' ' pass'
+% timeit.py 'try:' ' str.__bool__' 'except AttributeError:' ' pass'
100000 loops, best of 3: 15.7 usec per loop
-% timeit.py 'if hasattr(str, "__nonzero__"): pass'
+% timeit.py 'if hasattr(str, "__bool__"): pass'
100000 loops, best of 3: 4.26 usec per loop
-% timeit.py 'try:' ' int.__nonzero__' 'except AttributeError:' ' pass'
+% timeit.py 'try:' ' int.__bool__' 'except AttributeError:' ' pass'
1000000 loops, best of 3: 1.43 usec per loop
-% timeit.py 'if hasattr(int, "__nonzero__"): pass'
+% timeit.py 'if hasattr(int, "__bool__"): pass'
100000 loops, best of 3: 2.23 usec per loop
\end{verbatim}
@@ -176,7 +176,7 @@ missing and present object attributes.
>>> import timeit
>>> s = """\
... try:
-... str.__nonzero__
+... str.__bool__
... except AttributeError:
... pass
... """
@@ -184,14 +184,14 @@ missing and present object attributes.
>>> print "%.2f usec/pass" % (1000000 * t.timeit(number=100000)/100000)
17.09 usec/pass
>>> s = """\
-... if hasattr(str, '__nonzero__'): pass
+... if hasattr(str, '__bool__'): pass
... """
>>> t = timeit.Timer(stmt=s)
>>> print "%.2f usec/pass" % (1000000 * t.timeit(number=100000)/100000)
4.85 usec/pass
>>> s = """\
... try:
-... int.__nonzero__
+... int.__bool__
... except AttributeError:
... pass
... """
@@ -199,7 +199,7 @@ missing and present object attributes.
>>> print "%.2f usec/pass" % (1000000 * t.timeit(number=100000)/100000)
1.97 usec/pass
>>> s = """\
-... if hasattr(int, '__nonzero__'): pass
+... if hasattr(int, '__bool__'): pass
... """
>>> t = timeit.Timer(stmt=s)
>>> print "%.2f usec/pass" % (1000000 * t.timeit(number=100000)/100000)
diff --git a/Doc/lib/libwinreg.tex b/Doc/lib/libwinreg.tex
index d1e23da..3853997 100644
--- a/Doc/lib/libwinreg.tex
+++ b/Doc/lib/libwinreg.tex
@@ -375,7 +375,7 @@ This module offers the following functions:
also accept an integer, however, use of the handle object is
encouraged.
- Handle objects provide semantics for \method{__nonzero__()} - thus
+ Handle objects provide semantics for \method{__bool__()} - thus
\begin{verbatim}
if handle:
print "Yes"
diff --git a/Doc/lib/libxmlrpclib.tex b/Doc/lib/libxmlrpclib.tex
index 3645b82..b08920c 100644
--- a/Doc/lib/libxmlrpclib.tex
+++ b/Doc/lib/libxmlrpclib.tex
@@ -171,7 +171,7 @@ Hacks}{http://xmlrpc-c.sourceforge.net/hacks.php} page.
This class may be initialized from any Python value; the instance
returned depends only on its truth value. It supports various Python
operators through \method{__cmp__()}, \method{__repr__()},
-\method{__int__()}, and \method{__nonzero__()} methods, all
+\method{__int__()}, and \method{__bool__()} methods, all
implemented in the obvious ways.
It also has the following method, supported mainly for internal use by
diff --git a/Doc/ref/ref3.tex b/Doc/ref/ref3.tex
index 83277f4..7eddfcd 100644
--- a/Doc/ref/ref3.tex
+++ b/Doc/ref/ref3.tex
@@ -1313,13 +1313,13 @@ of that object]{2.5}
\withsubitem{(object method)}{\ttindex{__cmp__()}}
\end{methoddesc}
-\begin{methoddesc}[object]{__nonzero__}{self}
+\begin{methoddesc}[object]{__bool__}{self}
Called to implement truth value testing, and the built-in operation
-\code{bool()}; should return \code{False} or \code{True}, or their
-integer equivalents \code{0} or \code{1}.
+\code{bool()}; should return \code{False} or \code{True}.
When this method is not defined, \method{__len__()} is
-called, if it is defined (see below). If a class defines neither
-\method{__len__()} nor \method{__nonzero__()}, all its instances are
+called, if it is defined (see below) and \code{True} is returned when
+the length is not zero. If a class defines neither
+\method{__len__()} nor \method{__bool__()}, all its instances are
considered true.
\withsubitem{(mapping object method)}{\ttindex{__len__()}}
\end{methoddesc}
@@ -1693,9 +1693,9 @@ through the values.
Called to implement the built-in function
\function{len()}\bifuncindex{len}. Should return the length of the
object, an integer \code{>=} 0. Also, an object that doesn't define a
-\method{__nonzero__()} method and whose \method{__len__()} method
+\method{__bool__()} method and whose \method{__len__()} method
returns zero is considered to be false in a Boolean context.
-\withsubitem{(object method)}{\ttindex{__nonzero__()}}
+\withsubitem{(object method)}{\ttindex{__bool__()}}
\end{methoddesc}
\begin{methoddesc}[container object]{__getitem__}{self, key}