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.
61 lines
732 B
61 lines
732 B
# del global
|
|
|
|
def do_del():
|
|
global x
|
|
del x
|
|
|
|
x = 1
|
|
print(x)
|
|
do_del()
|
|
try:
|
|
print(x)
|
|
except NameError:
|
|
print("NameError")
|
|
try:
|
|
do_del()
|
|
except: # NameError:
|
|
# FIXME uPy returns KeyError for this
|
|
print("NameError")
|
|
|
|
# delete globals using a list
|
|
|
|
a = 1
|
|
del (a,)
|
|
try:
|
|
print(a)
|
|
except NameError:
|
|
print("NameError")
|
|
|
|
a = 2
|
|
b = 3
|
|
del (a, b)
|
|
try:
|
|
print(a)
|
|
except NameError:
|
|
print("NameError")
|
|
try:
|
|
print(b)
|
|
except NameError:
|
|
print("NameError")
|
|
|
|
a = 1
|
|
b = 2
|
|
c = 3
|
|
del (a, b, c)
|
|
try:
|
|
print(a)
|
|
except NameError:
|
|
print("NameError")
|
|
try:
|
|
print(b)
|
|
except NameError:
|
|
print("NameError")
|
|
try:
|
|
print(c)
|
|
except NameError:
|
|
print("NameError")
|
|
|
|
a = 1
|
|
b = 2
|
|
c = 3
|
|
del (a, (b, c))
|
|
|