help with lists and writing to file in correct order

Scott David Daniels scott.daniels at acm.org
Mon Dec 26 23:23:42 EST 2005


homepricemaps at gmail.com wrote:
> the problem with writing to teh file immidiately is that it ends up
> writing all food items together, and then all store items and then all
> prices
> 
> i want
> 
> food, store, price
> food, store, price
> 
Well, if it all fits in memory, append each to its own list, and then
either finally if you can or periodically if you must:

     for food, store, price in zip(foods, stores, prices):
         <do some writing.>

-- 
-Scott David Daniels
scott.daniels at acm.org



More information about the Python-list mailing list