1class C: 2 def f(): 3 pass 4 5# del a class attribute 6 7del C.f 8try: 9 print(C.x) 10except AttributeError: 11 print("AttributeError") 12try: 13 del C.f 14except AttributeError: 15 print("AttributeError") 16 17# del an instance attribute 18 19c = C() 20 21c.x = 1 22print(c.x) 23 24del c.x 25try: 26 print(c.x) 27except AttributeError: 28 print("AttributeError") 29try: 30 del c.x 31except AttributeError: 32 print("AttributeError") 33 34# try to del an attribute of a built-in class 35try: 36 del int.to_bytes 37except (AttributeError, TypeError): 38 # uPy raises AttributeError, CPython raises TypeError 39 print('AttributeError/TypeError') 40