On 02/11/2016 06:27 PM, Lars Gustäbel wrote: > On Thu, Feb 11, 2016 at 04:41:43PM +0000, Ulli Horlacher wrote: >> sfo = sock.makefile('r') >> taro = tarfile.open(fileobj=sfo,mode='r|') >> taro.extractall(path=edir) > What about using an iterator? > > def myiter(tar): > for t in tar: > print "extracting", t.name > yield t > > sfo = sock.makefile('r') > taro = tarfile.open(fileobj=sfo,mode='r|') > taro.extractall(members=myiter(taro),path=edir) > > Cheers,
The tarfile is already an iterator. Just do the following: for ti in taro: print "extracting", ti.name taro.extract(ti) -- https://mail.python.org/mailman/listinfo/python-list