-
Notifications
You must be signed in to change notification settings - Fork 0
Magic methods
RauliL edited this page Oct 5, 2014
·
1 revision
Method | Description |
---|---|
_bool_ | Boolean representation of object. |
_str_ | String representation of object. |
Method | Operator |
---|---|
_add_ | + |
_sub_ | - |
_mul_ | * |
_div_ | / |
_mod_ | % |
_and_ | & |
_or_ | | |
_xor_ | ^ |
_lsh_ | << |
_rsh_ | >> |
_cmp_ | <=> |
_eq_ | == |
_lt_ | < |
_gt_ | > |
_lte_ | <= |
_gte_ | >= |
_pos_ | Unary + |
_neg_ | Unary - |
_invert_ | ~ |
_inc_ | ++ |
_dec_ | -- |
Operator !=
is just negated version of ==
, e.g. !(foo == bar)
.
Method | Example |
---|---|
_getitem_ | foo[...] |
_setitem_ | foo[...] = ... |
Maybe these should be just __get__
and __set__
?