[Tutor] reading file creation date and xreadlines from a pointin the middle of a file

Jim Ragsdale overlord@netdoor.com
Tue, 5 Feb 2002 10:49:29 -0600


[Danny Yoo]
Your class looks promising, Im going to experiment w/ it for a while.
Thanks!

----- Original Message -----
From: "Danny Yoo" <dyoo@hkn.eecs.berkeley.edu>
To: "Jim Ragsdale" <overlord@netdoor.com>
Cc: "Python Tutor Mailing List" <tutor@python.org>
Sent: Monday, February 04, 2002 8:37 PM
Subject: Re: [Tutor] reading file creation date and xreadlines from a
pointin the middle of a file


> On Mon, 4 Feb 2002, Jim Ragsdale wrote:
>
> > I have looked around and have not found a way (that I could
> > understand) to read the creation date of a file. Does anyone know how
> > to do it? Not necessary but cross platform would be nice. win32 is the
> > target.
>
>
> There are actually two functions in os.path called getatime() and
> getmtime, respectively for "access" and "modification" times:
>
>     http://www.python.org/doc/lib/module-os.path.html
>
> os.path.getmtime() is probably what you're looking for:
>
> ###
> >>> os.path.getmtime('/var/mail/dyoo')
> 1012873750
> >>> from time import localtime
> >>> localtime(os.path.getmtime('/var/mail/dyoo'))
> (2002, 2, 4, 17, 49, 10, 0, 35, 0)
> ###
>
>
> I'm not sure if the system maintains a "creation" time flag, as it's sorta
> arguable that modification is similar to creation.  Perhaps someone else
> may be able to find out about this?
>
>
>
> > Another question: I am using xreadlines. How do I start reading at a
> > specified line in a file?
>
> xreadlines() might not be an appropriate function because it assumes you
> want to read through the file sequentially, one line at a time.  If we
> suck up the whole file as a list of lines by using readlines(), we can
> grab any line by doing an array index, so readlines() is probably a better
> choice.
>
>
> I've written a quicky RandomFile class that I think might be more
> memory-efficient if you're concerned about memory usage:
>
>     http://aspn.activestate.com/ASPN/Mail/Message/989629
>
>
> Good luck to you!
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor