TheDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
//= operator is the augmented assignment operator for floor division. It divides the left operand by the right operand, applies the floor function to the quotient (rounding down towards negative infinity), and assigns the resulting value back to the left operand.
x = x // y, augmented assignment evaluates the left-hand side expression exactly once. This is a critical distinction when the left operand involves a function call, property access, or complex indexing:
Technical Mechanics
Type Coercion and Return Types The data type of the resulting assignment depends on the types of the operands involved:- If both operands are integers (
int), the result assigned to the left operand is anint. - If either operand is a floating-point number (
float), the result assigned to the left operand is afloatrepresenting a whole number.
-10 / 3 evaluates to -3.333.... Applying the floor function rounds this down to -4, not -3.
Zero Division
If the right operand evaluates to zero (e.g., x //= 0 or x //= 0.0), Python raises a ZeroDivisionError. This semantic rule applies universally to all division-based operators in Python.
Object Model Implementation
When the Python interpreter encounters x //= y, it resolves the operation through the following sequence:
- It attempts to invoke the in-place magic method
__ifloordiv__(self, other)on the left operand. If implemented (typically by mutable custom types), the operation modifies the object in-place and returns it. - If
__ifloordiv__is not implemented, Python falls back to the standard floor division method__floordiv__(self, other)and binds the resulting new object back to the target variable name.
int and float do not implement __ifloordiv__ at all. They rely entirely on the __floordiv__ fallback, meaning a new numeric object is always allocated and reassigned to the variable.
Evaluation Examples
Master Python with Deep Grasping Methodology!Learn More





