time.ctime(os.path.getmtime(myFile)) results in TypeError: coercing to Unicode: need string or buffer, file found
Question: Newbie question here.

I'm trying the code provided from: [How to get file creation & modification
date/times in Python?](http://stackoverflow.com/questions/237079/how-to-get-
file-creation-modification-date-times-in-python)

The exact code I'm running is:

    
    
    # -*- coding: utf-8 -*-
    import os.path, time
    myFile = open('IMG_4847.PNG', 'rb')
    print "last modified: %s" % time.ctime(os.path.getmtime(myFile))
    

But, I'm getting the following error:

    
    
    Traceback (most recent call last):
     File "test.py", line 4, in <module>
       print "last modified: %s" % time.ctime(os.path.getmtime(myFile))
      File "C:\Python27\lib\genericpath.py", line 54, in getmtime
        return os.stat(filename).st_mtime
    TypeError: coercing to Unicode: need string or buffer, file found
    

What am I missing here?


Answer: 
    import os.path, time
    print "last modified: %s" % time.ctime(os.path.getmtime('IMG_4847.PNG'))
    

You pass a filepath to `getmtime`, not a file object.

