7 odpowiedzi
+ 8
Nope, prefixes and postfixes are not available in Python.
Prefixes will just represent operators, so:
--x will be equal to x
++x will also be equal to x
Postfixes will raise the SyntaxError exception.
+ 12
Adding to what Tom said:
x += y ➡️ x = x + y
x -= y ➡️ x = x - y
x *= y ➡️ x = x * y
x /= y ➡️ x = x / y
x //= y ➡️ x = x // y
x **= y ➡️ x = x ** y
x %= y ➡️ x = x % y
Same goes for bitwise operators:
x &= y ➡️ x = x & y
x |= y ➡️ x = x | y
x ^= y ➡️ x = x ^ y
And don't get it confused with:
x != y ➡️ is x different than y ;)
+ 10
It is a bitwise XOR operator. It assumes True only when both arguments are of different boolean values:
True ^ False == True
True ^ True == False
False ^ True == True
False ^ False == False
+ 5
x += 1
x-=1
I guess(Not py pro)
+ 3
Kuba Siekierzyński
x ^= y?
what do you use that for
+ 3
Kuba Siekierzyński
ok thanks for all the helpful answers
+ 2
Kuba Siekierzyński what should I use as a alternative?