[CentralOH] Improving Zipfile Code

Mark Erbaugh mark at microenh.com
Mon Oct 22 06:40:39 CEST 2012


What's the smell you're concerned about?

Sent from my iPad

On Oct 21, 2012, at 10:46 PM, jep200404 at columbus.rr.com wrote:

> The following code smells. How would you improve it? 
> 
> import csv
> from zipfile import ZipFile
> 
> def foo(filename):
>    z = ZipFile(filename)
>    for f in filter((lambda s: s.endswith('.xyz')), z.namelist()):
>        for line_number, row in enumerate(csv.DictReader(z.open(f, 'rU')), 2):
>            print 'line_number:', line_number, 'row:', row
> 
> _______________________________________________
> CentralOH mailing list
> CentralOH at python.org
> http://mail.python.org/mailman/listinfo/centraloh


More information about the CentralOH mailing list