Bootstrap

python code(1)

 1 from collections import UserList
 2 class MthChianList(UserList):
 3     def filter(self,predicste):
 4         return MthChianList(elem for elem in self if predicste(elem))
 5     def map(self,mapper):
 6         return MthChianList(mapper(elem) for elem in self)
 7     def for_each(self,action):
 8         for elem in self:
 9             action(elem)
10 lt=MthChianList(['A','B','c','d','e','F'])
11 lt.filter(str.islower).map(str.upper).for_each(print)

 

转载于:https://www.cnblogs.com/larken/p/10585210.html

;