1 # tests basics of bound methods 2 3 # uPy and CPython differ when printing a bound method, so just print the type 4 print(type(repr([].append))) 5 6 class A: 7 def f(self): 8 return 0 9 def g(self, a): 10 return a 11 def h(self, a, b, c, d, e, f): 12 return a + b + c + d + e + f 13 14 # bound method with no extra args 15 m = A().f 16 print(m()) 17 18 # bound method with 1 extra arg 19 m = A().g 20 print(m(1)) 21 22 # bound method with lots of extra args 23 m = A().h 24 print(m(1, 2, 3, 4, 5, 6)) 25 26 # can't assign attributes to a bound method 27 try: 28 A().f.x = 1 29 except AttributeError: 30 print('AttributeError') 31