[Tutor] Program to report if file was modified today
David
david at abbottdavid.com
Thu Feb 12 16:48:05 CET 2009
Kent Johnson wrote:
> On Wed, Feb 11, 2009 at 11:21 PM, bob gailer <bgailer at gmail.com> wrote:
>
>
Thanks Alan and Kent,
This works as expected;
<code>
#!/usr/bin/python
import sys
import os
import time
def mod():
"""Find files modified today, given a file path."""
now = time.strftime('%Y-%m-%d', time.localtime())
dir = os.path.dirname(sys.argv[1])
for fname in os.listdir(dir):
if fname.endswith('.py'):
modtime = os.stat(os.path.join(dir, fname)).st_mtime
out = time.strftime('%Y-%m-%d', time.localtime(modtime))
if out == now:
print fname, "has changed today. "
mod()
</code>
-david
--
powered by Gentoo/GNU Linux
http://linuxcrazy.com
More information about the Tutor
mailing list