The stat Module: File Statistics : Introduction « File « Python Tutorial

import os, sys
from stat import *

sName = "test.txt"

if os.access( sName, os.F_OK ) == False :
    print "That file name doesn't exist!"

sStat = os.stat( sName )

mMode= sStat[ST_MODE]
if S_ISDIR(mMode) :
    print "The path is a directory"
elif S_ISREG(mMode) :
    print "The path is a file"
else :
    print "I have no idea what the path is"

userID = sStat[ST_UID]
print str(userID)

fSize = sStat[ST_SIZE]
print str(fSize)

accessTime = sStat[ST_ATIME]
print str(accessTime)
modTime = sStat[ST_MTIME]
print str(modTime)

12.1.1.os and os.path Modules
12.1.2.The stat Module: File Statistics