[Tutor] printing files
ALAN GAULD
alan.gauld at btinternet.com
Thu Mar 26 19:58:04 CET 2009
Use '\n'.join(handle[1:])
It will create a string from your list with newline as separator.
Alan Gauld
Author of the Learn To Program website
http://www.alan-g.me.uk/
________________________________
From: Bala subramanian <bala.biophysics at gmail.com>
To: Alan Gauld <alan.gauld at btinternet.com>
Sent: Thursday, 26 March, 2009 6:11:59 PM
Subject: Re: [Tutor] printing files
yes you are right,
When i use the following
print>>out, handle[1:]
In the out file, it saves the lines as a list rather than as a string. How to avoid this.
Bala
On Thu, Mar 26, 2009 at 7:05 PM, Alan Gauld <alan.gauld at btinternet.com> wrote:
"Bala subramanian" <bala.biophysics at gmail.com> wrote
for files in flist:
handle=open(flist).readlines()
print>>out, handle
print>>out, handle[1:]
Should do it? You might need to handle line endings though...
Alan G.
_______________________________________________
Tutor maillist - Tutor at python.org
http://mail.python.org/mailman/listinfo/tutor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090326/c642107e/attachment-0001.htm>
More information about the Tutor
mailing list