Python拾遺の特殊関数_len__
1264 ワード
# -*- coding: utf-8 -*-
"""
list len()
。 , __len__(),
, , __len__() , len() Family “ ”
"""
class Family(object):
def __init__(self, *args):
self.names = args
def __len__(self):
# ,
return len(self.names)
if __name__ == '__main__':
menber = Family('Dada', 'Mama', 'You')
print len(menber)