mirror of
https://github.com/kennethreitz/dive-into-python3.git
synced 2026-06-05 23:10:17 +00:00
more notes on special-method-names
This commit is contained in:
+34
-34
@@ -96,21 +96,21 @@ class OrderedDict(dict, collections.MutableMapping):
|
||||
|
||||
Basics:
|
||||
|
||||
__init__
|
||||
__repr__
|
||||
__str__
|
||||
__init__ - covered in iterators.html
|
||||
__repr__ - covered in ordereddict.py
|
||||
__str__ - covered in fractions.py
|
||||
__bytes__ (*)
|
||||
__format__
|
||||
|
||||
Rich comparisons:
|
||||
|
||||
__lt__
|
||||
__le__
|
||||
__eq__
|
||||
__lt__ - covered in fractions.py
|
||||
__le__ - covered in fractions.py
|
||||
__eq__ - covered in ordereddict.py, fractions.py
|
||||
__ne__
|
||||
__gt__
|
||||
__ge__
|
||||
__bool__
|
||||
__gt__ - covered in fractions.py
|
||||
__ge__ - covered in fractions.py
|
||||
__bool__ - covered in fractions.py
|
||||
__cmp__ (*)
|
||||
|
||||
Custom attributes:
|
||||
@@ -128,7 +128,7 @@ __call__
|
||||
Acts like a list:
|
||||
|
||||
__len__
|
||||
__reversed__
|
||||
__reversed__ - covered in ordereddict.py
|
||||
__contains__
|
||||
__index__
|
||||
__getslice__ (*)
|
||||
@@ -136,37 +136,37 @@ __getslice__ (*)
|
||||
Acts like a dictionary:
|
||||
|
||||
__getitem__
|
||||
__setitem__
|
||||
__delitem__
|
||||
__setitem__ - covered in ordereddict.py
|
||||
__delitem__ - covered in ordereddict.py
|
||||
__missing__ (*)
|
||||
|
||||
Acts like an iterator:
|
||||
|
||||
__iter__ (*)
|
||||
__next__ (*)
|
||||
__iter__ (*) - covered in iterators.html
|
||||
__next__ (*) - covered in iterators.html
|
||||
|
||||
Acts like a number:
|
||||
|
||||
__add__
|
||||
__add__ - covered in fractions.py
|
||||
__sub__
|
||||
__mul__
|
||||
__truediv__
|
||||
__floordiv__
|
||||
__mod__
|
||||
__floordiv__ - covered in fractions.py
|
||||
__mod__ - covered in fractions.py
|
||||
__divmod__
|
||||
__pow__
|
||||
__pow__ - covered in fractions.py
|
||||
__lshift__
|
||||
__rshift__
|
||||
__and__
|
||||
__xor__
|
||||
__or__
|
||||
__radd__
|
||||
__radd__ - covered in fractions.py
|
||||
__rsub__
|
||||
__rmul__
|
||||
__rtruediv__
|
||||
__rfloordiv__
|
||||
__rmod__
|
||||
__rpow__
|
||||
__rfloordiv__ - covered in fractions.py
|
||||
__rmod__ - covered in fractions.py
|
||||
__rpow__ - covered in fractions.py
|
||||
__rlshift__
|
||||
__rrshift__
|
||||
__rand__
|
||||
@@ -184,36 +184,36 @@ __irshift__
|
||||
__iand__
|
||||
__ixor__
|
||||
__ior__
|
||||
__neg__
|
||||
__pos__
|
||||
__abs__
|
||||
__neg__ - covered in fractions.py
|
||||
__pos__ - covered in fractions.py
|
||||
__abs__ - covered in fractions.py
|
||||
__invert__
|
||||
__complex__
|
||||
__int__
|
||||
__float__
|
||||
__long__ (*)
|
||||
__round__
|
||||
__ceil__ (*)
|
||||
__floor__ (*)
|
||||
__trunc__ (*)
|
||||
__round__ - covered in fractions.py
|
||||
__ceil__ (*) - covered in fractions.py
|
||||
__floor__ (*) - covered in fractions.py
|
||||
__trunc__ (*) - covered in fractions.py
|
||||
|
||||
Support for pickling, see http://docs.python.org/3.0/library/pickle.html:
|
||||
|
||||
__copy__ (*)
|
||||
__deepcopy__ (*)
|
||||
__copy__ (*) - covered in fractions.py
|
||||
__deepcopy__ (*) - covered in fractions.py
|
||||
__getnewargs__ (*)
|
||||
__getinitargs__ (*)
|
||||
__getstate__ (*)
|
||||
__setstate__ (*)
|
||||
__reduce__ (*)
|
||||
__reduce__ (*) - covered in ordereddict.py, fractions.py
|
||||
__reduce_ex__ (*)
|
||||
|
||||
Really weird stuff:
|
||||
|
||||
__new__
|
||||
__new__ - covered in fractions.py
|
||||
__del__
|
||||
__slots__
|
||||
__hash__
|
||||
__hash__ - covered in fractions.py
|
||||
__get__
|
||||
__set__
|
||||
__delete__
|
||||
|
||||
Reference in New Issue
Block a user