You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
414 B
33 lines
414 B
11 years ago
|
class C:
|
||
|
def f():
|
||
|
pass
|
||
|
|
||
11 years ago
|
# 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")
|