Re: [Tutor] Writing/reading lists to a file

2005-12-27 Thread Liam Clarke
Hi Hans, If you're looking to store lists as lists, may I recommend the cPickle module? It's good for most times when you want to store an object as an object. >>> import cPickle >>> a = [1,2,3] >>> b = [4,5,6] >>> c = [7,8,9] >>> d = [a,b,c] >>> d [[1, 2, 3], [4, 5, 6], [7, 8, 9]] >>> print d[0]

[Tutor] Writing/reading lists to a file

2005-12-27 Thread Hans Dushanthakumar
Hi, Is there any easy way of writing lists to a file and more importantly, reading it back as a list of lists rather than as a list of strings. Eg: >>> t = ["t1", "PASS", 31] >>> f = open("pass.txt","a+") >>> f.write(str(t) + "\n") >>> f.write(str(t) + "\n") >>> f.close() At this stage, the