1class C1: 2 def __init__(self, value): 3 self.value = value 4 5 def __str__(self): 6 return "str<C1 {}>".format(self.value) 7 8class C2: 9 def __init__(self, value): 10 self.value = value 11 12 def __repr__(self): 13 return "repr<C2 {}>".format(self.value) 14 15class C3: 16 def __init__(self, value): 17 self.value = value 18 19 def __str__(self): 20 return "str<C3 {}>".format(self.value) 21 22 def __repr__(self): 23 return "repr<C3 {}>".format(self.value) 24 25c1 = C1(1) 26print(c1) 27 28c2 = C2(2) 29print(c2) 30 31s11 = str(c1) 32print(s11) 33# This will use builtin repr(), which uses id(), which is of course different 34# between CPython and MicroPython 35s12 = repr(c1) 36print("C1 object at" in s12) 37 38s21 = str(c2) 39print(s21) 40s22 = repr(c2) 41print(s22) 42 43c3 = C3(1) 44print(c3) 45