我构建了一个类:
class Foo (object):
def __init__(self,List):
self.List=List
@property
def numbers(self):
L=[]
for i in self.List:
if i.isdigit():
L.append(i)
return L
@property
def letters(self):
L=[]
for i in self.List:
if i.isalpha():
L.append(i)
return L
>>> inst=Foo(['12','ae','45','bb'])
>>> inst.letters
['ae', 'bb']
>>> inst.numbers
['12', '45']
我怎样才能添加属性,所以我可以这样做inst.numbers.odd
会返回['45']
?