8000 replace references to __nonzero__ with __bool__ · python/cpython@6297128 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6297128

Browse files
committed
replace references to __nonzero__ with __bool__
1 parent 030debb commit 6297128

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Misc/cheatsheet

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ x and y if x is False then x, else (1)
269269

270270
Notes :
271271
Truth testing behavior can be overridden for a given class by defining
272-
special method __nonzero__.
272+
special method __bool__.
273273
(1) Evaluate second arg only if necessary to determine outcome.
274274

275275
None
@@ -1143,7 +1143,7 @@ Special methods for any class
11431143
__cmp__(s, o) Compares s to o and returns <0, 0, or >0.
11441144
Implements >, <, == etc...
11451145
__hash__(s) Compute a 32 bit hash code; hash() and dictionary ops
1146-
__nonzero__(s) Returns False or True for truth value testing
1146+
__bool__(s) Returns False or True for truth value testing
11471147
__getattr__(s, name) called when attr lookup doesn't find <name>
11481148
__setattr__(s, name, val) called when setting an attr
11491149
(inside, don't use "self.name = value"
@@ -1167,7 +1167,7 @@ Operators
11671167
s&o = __and__(s,o)
11681168
s^o = __xor__(s,o) s|o = __or__(s,o)
11691169
s<<o = __lshift__(s,o) s>>o = __rshift__(s,o)
1170-
nonzero(s) = __nonzero__(s) (used in boolean testing)
1170+
bool(s) = __bool__(s) (used in boolean testing)
11711171
-s = __neg__(s) +s = __pos__(s)
11721172
abs(s) = __abs__(s) ~s = __invert__(s) (bitwise)
11731173
s+=o = __iadd__(s,o) s-=o = __isub__(s,o)

0 commit comments

Comments
 (0)
0