[Tutor] printing files

Marc Tompkins marc.tompkins at gmail.com
Thu Mar 26 18:56:10 CET 2009

On Thu, Mar 26, 2009 at 10:42 AM, Bala subramanian <
bala.biophysics at gmail.com> wrote:

>    print>>out, handle  <-- Here i want to write only from second line. I
> dnt want to loop over handle here and putting all lines except the first one
> in
>                                             another variable. Is there any
> fancy way of doing it.

Without changing anything else, you could do it with a slice:

> out=open('all','w')
> for files in flist:
>    handle=open(flist).readlines()
>    print>>out, handle[1:]  # start with second item (indexes start at 0,
> remember) and go to end
> out.close()

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090326/ec629870/attachment.htm>

More information about the Tutor mailing list