(no subject)

Tue Mar 1 17:55:02 CET 2005

#! 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!!attcg2!ip.att.net!xyzzy!nntp
From: Jeff Sandys <sandysj at juno.com>
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: <42249B1E.7F741A2 at juno.com>
Sender: nntp at news.boeing.com (Boeing NNTP News Access)
Content-Transfer-Encoding: 8bit
Organization: juno
X-Accept-Language: en
References: <d01n3e$c61$1 at news.uit.no>
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

More information about the Python-list mailing list