forked from MicroPythonOS/MicroPythonOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuserlist.py
More file actions
29 lines (19 loc) · 651 Bytes
/
userlist.py
File metadata and controls
29 lines (19 loc) · 651 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# for micropython compatibility
class UserList:
def __init__(self, initlist=None):
self.data = list(initlist) if initlist is not None else []
# Support basic list operations
def __getitem__(self, index):
return self.data[index]
def __setitem__(self, index, value):
self.data[index] = value
def __len__(self):
return len(self.data)
def __iter__(self):
return iter(self.data)
def append(self, item):
self.data.append(item)
def extend(self, other):
self.data.extend(other)
def __repr__(self):
return f"{self.__class__.__name__}({self.data!r})"