Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python 3.4.2 urlib no attribute 'pathname2url'

Tags:

python

urllib

Why is the next code not working? I cant find why.

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 get is:

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

I am trying display all file typs of a directory. Is this a good way? Or is there a better way. I dont want to use the module magic.

like image 826
joey Avatar asked Jun 04 '15 21:06

joey


1 Answers

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

like image 170
MattDMo Avatar answered Sep 22 '22 13:09

MattDMo