Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (50.2k points)

I was working on some code in Python and I came across a package named:

from six.moves import urllib

I cannot find the urllib.py anywhere. I found that there is a file six.py file in the root package and it has class Module_six_moves_urllib(types.ModuleType).

1 Answer

0 votes
by (107k points)

Kindly be informed that the 'six' library will help you to write the code that is compatible with both Python 2 and Python 3.

The six.moves package will provide those modules under a general name for both Python2 and 3:

from six.moves import urllib

The above code will import urllib when run with Python3 and it will import a mixture of urllib, urllib2, and urlparse with Python2.

Related questions

0 votes
1 answer
asked Dec 22, 2020 in Python by ashely (50.2k points)
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...