micropython: add micropython component
This commit is contained in:
15
components/language/micropython/tests/basics/class_number.py
Normal file
15
components/language/micropython/tests/basics/class_number.py
Normal file
@@ -0,0 +1,15 @@
|
||||
# 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
|
Reference in New Issue
Block a user