Skip to content

Commit 6c74962

Browse files
committed
Quick-start guide: describe urllib situation
1 parent 27305ca commit 6c74962

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

docs/quickstart.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,25 @@ be accessed under their Python 3 names and locations in Python 2::
101101
import xmlrpc.client
102102
import xmlrpc.server
103103

104-
``urllib`` currently requires explicit imports because the name clashes with that on Python 2::
104+
``urllib`` currently requires an explicit import because the name clashes with
105+
that on Python 2 and because Python's syntax does not allow imports of this
106+
form with a dotted module name after ``as``::
107+
108+
import future.moves.urllib.parse as urllib.parse
109+
110+
For submodules of ``urllib`` and other packages (like ``http``), this
111+
alternative form is available::
105112

106113
from future.standard_library import import_
114+
107115
urllib = import_('urllib')
108116
import_('urllib.parse')
109117
import_('urllib.request')
110118
import_('urllib.error')
111119

120+
response = urllib.request.urlopen('http://mywebsite.com')
121+
# etc.
122+
112123
For an explanation of these and other forms of imports from the standard
113124
library, see :ref:`standard-library-imports`.
114125

0 commit comments

Comments
 (0)