We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0f0de02 commit 60f2914Copy full SHA for 60f2914
tests/snippets/subtraction.py
@@ -0,0 +1,21 @@
1
+assert 5 - 3 == 2
2
+
3
+class Complex():
4
+ def __init__(self, real, imag):
5
+ self.real = real
6
+ self.imag = imag
7
8
+ def __repr__(self):
9
+ return "Com" + str((self.real, self.imag))
10
11
+ def __sub__(self, other):
12
+ return Complex(self.real - other, self.imag)
13
14
+ def __rsub__(self, other):
15
+ return Complex(other - self.real, -self.imag)
16
17
+ def __eq__(self, other):
18
+ return self.real == other.real and self.imag == other.imag
19
20
+assert Complex(4, 5) - 3 == Complex(1, 5)
21
+assert 7 - Complex(4, 5) == Complex(3, -5)
0 commit comments