help with lists and writing to file in correct order

homepricemaps at gmail.com homepricemaps at gmail.com
Mon Dec 26 23:56:17 EST 2005


sorry for asking such beginner questions but i tried this and nothing
wrote to my text file

for food, price, store in bs(food, price, store):
		out = open("test.txt", 'a')
		out.write (food + price + store)
        	                out.close()


while if i write the following without the for i at least get
something?
out = open("test.txt", 'a')
out.write (food + price + store)
out.close()


Scott David Daniels wrote:
> 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