mirror of
https://github.com/micropython/micropython.git
synced 2026-01-08 21:20:13 +01:00
py: Implement __delitem__ method for classes.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# test class with __getitem__ and __setitem__ methods
|
||||
# test class with __getitem__, __setitem__, __delitem__ methods
|
||||
|
||||
class C:
|
||||
def __getitem__(self, item):
|
||||
@@ -8,6 +8,10 @@ class C:
|
||||
def __setitem__(self, item, value):
|
||||
print('set', item, value)
|
||||
|
||||
def __delitem__(self, item):
|
||||
print('del', item)
|
||||
|
||||
c = C()
|
||||
print(c[1])
|
||||
c[1] = 2
|
||||
del c[3]
|
||||
|
||||
Reference in New Issue
Block a user