You've already forked Core2forAWS-MicroPython
mirror of
https://github.com/m5stack/Core2forAWS-MicroPython.git
synced 2026-05-20 10:30:31 -07:00
709136e844
Only use % formatting when testing % itself, because only str.format is guaranteed to be available on any port.
19 lines
329 B
Python
19 lines
329 B
Python
class A:
|
|
|
|
def __init__(self, v):
|
|
self.v = v
|
|
|
|
def __add__(self, o):
|
|
if isinstance(o, A):
|
|
return A(self.v + o.v)
|
|
return A(self.v + o)
|
|
|
|
def __radd__(self, o):
|
|
return A(self.v + o)
|
|
|
|
def __repr__(self):
|
|
return "A({})".format(self.v)
|
|
|
|
print(A(3) + 1)
|
|
print(2 + A(5))
|