micropython/tests/basics/class_number.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

16 lines
266 B
Python
Raw Normal View History

# test class with __add__ and __sub__ methods
class C:
def __init__(self, value):
self.value = value
def __add__(self, rhs):
print(self.value, '+', rhs)
def __sub__(self, rhs):
print(self.value, '-', rhs)
c = C(0)
c + 1
c - 2