Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
62971282
Commit
62971282
authored
Nov 30, 2006
by
Jack Diederich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replace references to __nonzero__ with __bool__
parent
030debb9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
Misc/cheatsheet
Misc/cheatsheet
+3
-3
No files found.
Misc/cheatsheet
View file @
62971282
...
...
@@ -269,7 +269,7 @@ x and y if x is False then x, else (1)
Notes :
Truth testing behavior can be overridden for a given class by defining
special method __
nonzero
__.
special method __
bool
__.
(1) Evaluate second arg only if necessary to determine outcome.
None
...
...
@@ -1143,7 +1143,7 @@ Special methods for any class
__cmp__(s, o) Compares s to o and returns <0, 0, or >0.
Implements >, <, == etc...
__hash__(s) Compute a 32 bit hash code; hash() and dictionary ops
__
nonzero
__(s) Returns False or True for truth value testing
__
bool
__(s) Returns False or True for truth value testing
__getattr__(s, name) called when attr lookup doesn't find <name>
__setattr__(s, name, val) called when setting an attr
(inside, don't use "self.name = value"
...
...
@@ -1167,7 +1167,7 @@ Operators
s&o = __and__(s,o)
s^o = __xor__(s,o) s|o = __or__(s,o)
s<<o = __lshift__(s,o) s>>o = __rshift__(s,o)
nonzero(s) = __nonzero
__(s) (used in boolean testing)
bool(s) = __bool
__(s) (used in boolean testing)
-s = __neg__(s) +s = __pos__(s)
abs(s) = __abs__(s) ~s = __invert__(s) (bitwise)
s+=o = __iadd__(s,o) s-=o = __isub__(s,o)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment