Operators
>>= — Right-shift assignment
Shift a built-in integer right by a nonnegative integer count. For integers this behaves like floor division by a power of two, including negative values. A negative shift count is invalid. The __irshift__() hook may modify its receiver or supply a replacement. If absent or declining with NotImplemented, normal binary dispatch applies. The result is stored back into the target; this is a statement, not an expression. A failed store does not guarantee rollback.
Formal Syntax & Structure
python syntaxpython
target >>= expressionParameters & Attributes
| Name | Type | Description |
|---|---|---|
| target | object | Existing assignable name, attribute, item or slice; its current value participates in the operation. |
| right | nonnegative integer shift count | Value used as the right operand of the operation. |
Working Example
Example Snippetpython
mask = 0b110100mask >>= 2negative = -7negative >>= 1print(mask)print(negative)