+ 1
what does this mean
in python wht does this code in bracket mean/ do in loops (i += 1)
2 Respuestas
+ 5
The operator(+=) is called assignment operator. It's similar to this
i = i+1
0
Magic Methods & Operator Overloading
https://www.sololearn.com/learning/1073/2470/5133/1
class Test(int):
def __init__(self, x):
self.x = x
def __iadd__(self, y):
print("__iadd__")
return Test(self.x + y)
a = Test(4)
a += 1
# __iadd__
print(a)
# 5