summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/del_attr.py
blob: bec7afb8483c7b1cea61b8c31456a88691bf6608 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
class C:
    def f():
        pass

# del a class attribute

del C.f
try:
    print(C.x)
except AttributeError:
    print("AttributeError")
try:
    del C.f
except AttributeError:
    print("AttributeError")

# del an instance attribute

c = C()

c.x = 1
print(c.x)

del c.x
try:
    print(c.x)
except AttributeError:
    print("AttributeError")
try:
    del c.x
except AttributeError:
    print("AttributeError")