[Pythonmac-SIG] os.path.getmtime bug?

Erik van Blokland erik@letterror.com
Sat, 4 Mar 2000 21:51:23 +0100


I'm sorry if this has come up in some other group already, but could this 
be a bug in the macpath module:
Simple example: getting the modification date of a file;
     import os
     path = "MoPar:Desktop Folder:Tijd.py"
     print os.path.getmtime(path)

>> NameError: stat
>File "<Untitled Script 1>", line 3, in ?
>File "macpath.py", line 112, in getmtime
>      return st[stat.ST_MTIME]

I looked in the macpath module, and it imports stuff from stat:
>from stat import *

However, there are still a couple of calls to the stat module directly:
>def getsize(filename):
>    """Return the size of a file, reported by os.stat()."""
>    st = os.stat(filename)
>    return st[stat.ST_SIZE]
>
>def getmtime(filename):
>    """Return the last modification time of a file, reported by os.stat()."""
>    st = os.stat(filename)
>    return st[stat.ST_MTIME]
>
>def getatime(filename):
>    """Return the last access time of a file, reported by os.stat()."""
>    st = os.stat(filename)
>    return st[stat.ST_MTIME]

As far as I can tell these can be fixed easily by taking out 'stat.', but 
maybe I'm missing something here?


Erik

-- letterror