Re: create a text file

2006-06-04 Thread Stan Cook
Fredrik Lundh wrote: > Stan Cook wrote: > >> I'm writing a script to list all of my music files' id3 tags to a >> comma delimited file. The only part I'm missing seems like it should >> be the simplest. I haven't used Python for the last couple of years. >> My question is this: >> >> When I

Re: create a text file

2006-05-31 Thread Ben Finney
"per9000" <[EMAIL PROTECTED]> writes: > appendix = '.txt' # or '.csv' or whatever > > # some code > > c += 1 > filetitle = 'result_' + zeropadding(c) + str(c) > myfile = open(filetitle+appendix,'w') Resist the urge to construct strings by concatenation, when Python's built-in string formatting

Re: create a text file

2006-05-31 Thread per9000
Ooops, w must be 'w' - sorry for adding more confusion :-D I would also like to add that this is a more realistic useage appendix = '.txt' # or '.csv' or whatever # some code c += 1 filetitle = 'result_' + zeropadding(c) + str(c) myfile = open(filetitle+appendix,'w') # etc Hope that was a l

Re: create a text file

2006-05-30 Thread Max Erickson
Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Max Erickson wrote: > >>> # w is for writing >>> myfile = open('theoutfile',w) >> >> That won't work, the second argument to open needs to be a string: > > w = 'w' > > > Is it inappropriate to call the w on the left side of the equal's sign a stri

Re: create a text file

2006-05-30 Thread Fredrik Lundh
Max Erickson wrote: >> # w is for writing >> myfile = open('theoutfile',w) > > That won't work, the second argument to open needs to be a string: w = 'w' -- http://mail.python.org/mailman/listinfo/python-list

Re: create a text file

2006-05-30 Thread Max Erickson
"per9000" <[EMAIL PROTECTED]> wrote: > # w is for writing > myfile = open('theoutfile',w) That won't work, the second argument to open needs to be a string: myfile = open('theoutfile', 'w') max -- http://mail.python.org/mailman/listinfo/python-list

Re: create a text file

2006-05-30 Thread per9000
Hi, This is what I often do: somekindofoutput = '' somekindofoutput += somefunk(somearg) + '\n' # w is for writing myfile = open('theoutfile',w) myfile.write(somekindofoutput) myfile.close() also see http://www.python.org/doc/2.3.5/tut/node9.html or some other documentation /P9k -- http://ma

Re: create a text file

2006-05-29 Thread Bruno Desthuilliers
Stan Cook a écrit : > I'm writing a script to list all of my music files' id3 tags to a comma > delimited file. The only part I'm missing seems like it should be the > simplest. I haven't used Python for the last couple of years. My > question is this: > > When I use os.open(,"w"), I get an

Re: create a text file

2006-05-29 Thread Fredrik Lundh
Stan Cook wrote: > I'm writing a script to list all of my music files' id3 tags > to a comma delimited file. The only part I'm missing seems > like it should be the simplest. I haven't used Python for > the last couple of years. My question is this: > > When I use os.open(,"w"), I get an er

create a text file

2006-05-29 Thread Stan Cook
I'm writing a script to list all of my music files' id3 tags to a comma delimited file. The only part I'm missing seems like it should be the simplest. I haven't used Python for the last couple of years. My question is this: When I use os.open(,"w"), I get an error message,TypeError