#! rnews 1106 Newsgroups: comp.lang.python Path: news.xs4all.nl!newsspool.news.xs4all.nl!transit.news.xs4all.nl!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!wns13feed!worldnet.att.net!12.120.4.37!attcg2!ip.att.net!xyzzy!nntp From: Jeff Sandys <[EMAIL PROTECTED]> Subject: Re: Delete first line from file X-Nntp-Posting-Host: e515855.nw.nos.boeing.com Content-Type: text/plain; charset=iso-8859-1 Message-ID: <[EMAIL PROTECTED]> Sender: [EMAIL PROTECTED] (Boeing NNTP News Access) Content-Transfer-Encoding: 8bit Organization: juno X-Accept-Language: en References: <[EMAIL PROTECTED]> Mime-Version: 1.0 Date: Tue, 1 Mar 2005 16:41:02 GMT X-Mailer: Mozilla 4.79 [en]C-CCK-MCD Boeing Kit (Windows NT 5.0; U) Xref: news.xs4all.nl comp.lang.python:365187 Lines: 23
You describe the standard behavior, unless you close the file, is that what you want to do; open file, read line 1, close file, then open file, read line 2, close file? The other suggestions here destory content, do you want that? >>> f = open("D:/Pydev/test.txt") >>> f.readline() 'line one\n' >>> f.readline() 'line two\n' >>> f.readline() 'line three\n' "Tor Erik Sřnvisen" wrote: > > Hi > > How can I read the first line of a file and then delete this line, so that > line 2 is line 1 on next read? > > regards -- http://mail.python.org/mailman/listinfo/python-list