1class A:
2
3    var = 132
4
5    def __init__(self):
6        self.var2 = 34
7
8
9a = A()
10setattr(a, "var", 123)
11setattr(a, "var2", 56)
12print(a.var)
13print(a.var2)
14
15try:
16    setattr(a, b'var3', 1)
17except TypeError:
18    print('TypeError')
19
20# try setattr on a built-in function
21try:
22    setattr(int, 'to_bytes', 1)
23except (AttributeError, TypeError):
24    # uPy raises AttributeError, CPython raises TypeError
25    print('AttributeError/TypeError')
26