class L(object):
    def __init__(self, lst):
        self.l = lst

    def __iter__(self):
        print('iter..')
        for l in self.l:
            yield l

    def __str__(self):
        return ' '.join(self.l)


l1 = L(['1', '2', '3'])
l2 = []
ll2+= l1
print(' '.join(l2))


$ ./a.py
iter..
1 2 3



'Language > Python' 카테고리의 다른 글

[Python] binding function parameter default value.  (0) 2015.09.06

+ Recent posts