Detecting the first time I open/append to a file

Scott David Daniels Scott.Daniels at Acm.Org
Tue Sep 23 23:11:13 EDT 2008


Terry Reedy wrote:
> tkpmep at hotmail.com wrote:
>> ...If I can sense that the file is being created in the first iteration,
>> I can then use an if statement to decide whether or not I need to
>> write the header. Question: how can I tell if the file is being
>> created or if this its the first iteration? ...
> 
> How about file.tell == 0? or have I misunderstood the requirement?

OI thought roughly the same thing when I saw this,
how about
     if not file.tell():
         <produce header>

--Scott David Daniels
Scott.Daniels at Acm.Org




More information about the Python-list mailing list