Python 3.4.2 urlib no attribute 'pathname2url'

Why doesn't the following code work? I cannot find the reason.

import mimetypes
import glob, urllib

for file in glob.glob("C:\\Users\\joey\\Desktop\\school\\ICOMMH"):
    url = urllib.pathname2url(file)
    print(file, mimetypes.guess_type(url))

      

The error message I receive is:

AttributeError: 'module' object has no attribute 'pathname2url'

      

I am trying to display all types of directory files. Is this a good way? Or is there a better way. I don't want to use module magic.

+3


source to share


1 answer


This function location has changed in Python 3. This is now urllib.request.pathname2url

.



+8


source







All Articles