Re: [Tutor] lists and strings

2005-11-08 Thread Kent Johnson
Mike Haft wrote: > All the ways of writing data to a file I know keep telling me that lists > can't be written to the file. I'm trying to convert data from one set of > files into files of a different format. But the easiest way to get the > data from the first set of files is in a list(s). > > So

Re: [Tutor] lists and strings

2005-11-08 Thread Christopher Arndt
Shantanoo Mahajan schrieb: > +++ Hugo Gonz?lez Monteverde [08-11-05 13:13 -0600]: > | Hi Mike, > | > | Converting an (almost)arbitrary object into a string is what the Pickle > module does. CPickle is faster. Take > | a look into into it in the docs. > | > > Is there a way to dump the varialbl

Re: [Tutor] lists and strings

2005-11-08 Thread Shantanoo Mahajan
+++ Hugo Gonz?lez Monteverde [08-11-05 13:13 -0600]: | Hi Mike, | | Converting an (almost)arbitrary object into a string is what the Pickle module does. CPickle is faster. Take | a look into into it in the docs. | Is there a way to dump the varialble in XML format and retrive it? e.g. a="this

Re: [Tutor] lists and strings

2005-11-08 Thread Pujo Aji
yes it is...   convert list to string:     L = [1,2,3]    L = [str(x) for x in L]    s = string.join(L,' ')    print len(s)  convert list to a file     myF = open(namaFile,"w")    for s in myList[:-1]:    myF.write(str(s)+"\n")    myF.write(str(myList[len(myList)-1]))    myF.close()    Cheers,

Re: [Tutor] lists and strings

2005-11-08 Thread Hugo González Monteverde
Hi Mike, Converting an (almost)arbitrary object into a string is what the Pickle module does. CPickle is faster. Take a look into into it in the docs. Here's an example: >>> import cPickle >>> lala = [1, 2, 3, 'four', 'V'] >>> lala [1, 2, 3, 'four', 'V'] >>> fileo = open('lala.pkl', 'w')