==UserList 模塊== ``UserList`` 模塊包含了一個可繼承的列表類 (事實上是對內建列表類型的 Python 封裝). 在 [Example 2-16 #eg-2-16] 中, //AutoList// 實例類似一個普通的列表對象, 但它允許你通過賦值為列表添加項目. ====Example 2-16. 使用 UserList 模塊====[eg-2-16] ``` File: userlist-example-1.py import UserList class AutoList(UserList.UserList): def _ _setitem_ _(self, i, item): if i == len(self.data): self.data.append(item) else: self.data[i] = item list = AutoList() for i in range(10): list[i] = i print list *B*[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]*b* ```