[Tutor] directory listing and file mod times
Mon, 27 Nov 2000 18:47:56 -0700
* temp <email@example.com>:
> >>> import os, time, stat
> >>> def fileinfo(filename):
> ... modified = stats[stat.ST_MTIME]
> ... print 'last modified :' + time.ctime(modified)
> >>> decode_stat.fileinfo('C:\Updates')
> Traceback (innermost last):
> File "<interactive input>", line 1, in ?
> NameError: There is no variable named 'decode_stat'
> It blows up here. I don't understand where 'decode_stat' came from and
> apparantly neither does Python.
And neither do I! It is useless in the context of your code, and is probably
just leftovers from the book.
Another thing that wont work is this:
modified = stats[stat.ST_MTIME]
This calls a dictionary that doesn't exist.
> Any ideas? (this could be 'operator error' related)
Changing the two problems above and making two cosmetic changes (fixing the
indention level and altering the print line) Yields:
import os, time, stat
modified = os.stat(filename)[stat.ST_MTIME]
print 'last modified:', time.ctime(modified)