Browse Source
This makes the runtime and object APIs more consistent. mp_store_subscr functionality now moved into objects (ie list and dict store_item).pull/454/head
Damien George
11 years ago
12 changed files with 107 additions and 40 deletions
@ -0,0 +1,28 @@ |
|||
# 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") |
@ -0,0 +1,18 @@ |
|||
# del global |
|||
|
|||
x = 1 |
|||
print(x) |
|||
del x |
|||
try: |
|||
print(x) |
|||
except NameError: |
|||
print("NameError") |
|||
try: |
|||
del x |
|||
except: # NameError: |
|||
# FIXME uPy returns KeyError for this |
|||
print("NameError") |
|||
|
|||
class C: |
|||
def f(): |
|||
pass |
@ -0,0 +1,13 @@ |
|||
l = [1, 2, 3] |
|||
print(l) |
|||
del l[0] |
|||
print(l) |
|||
del l[-1] |
|||
print(l) |
|||
|
|||
d = {1:2, 3:4, 5:6} |
|||
del d[1] |
|||
del d[3] |
|||
print(d) |
|||
del d[5] |
|||
print(d) |
Loading…
Reference in new issue