circuitpython/tests/basics/del-local.py
Damien George 2bf7c09222 py: Properly implement deletion of locals and derefs, and detect errors.
Needed to reinstate 2 delete opcodes, to specifically check that a local
is not deleted twice.
2014-04-09 15:26:46 +01:00

26 lines
377 B
Python

# delete local then try to reference it
def f():
x = 1
y = 2
print(x, y)
del x
print(y)
try:
print(x)
except NameError:
print("NameError");
f()
# delete local then try to delete it again
def g():
x = 3
y = 4
print(x, y)
del x
print(y)
try:
del x
except NameError:
print("NameError");
g()