篩選序列中的大於0元素
In [1]: from itertools import compress
In [2]: a = ['s', 'v', 'x']
In [3]: b = [1, 0, 7]
In [4]: more0 = [n > 0 for n in b]
In [5]: more0
Out[5]: [True, False, True]
In [6]: list(compress(a,b))
Out[6]: ['s', 'x']
篩選序列中的大於0元素
In [1]: from itertools import compress
In [2]: a = ['s', 'v', 'x']
In [3]: b = [1, 0, 7]
In [4]: more0 = [n > 0 for n in b]
In [5]: more0
Out[5]: [True, False, True]
In [6]: list(compress(a,b))
Out[6]: ['s', 'x']
class MetaCls(type): def __new__(cls, *args, **kwargs): print("in MetaCls") # return super(Meta