D
D
Drovosek012019-03-14 14:59:18
Python
Drovosek01, 2019-03-14 14:59:18

How to enable variable hints in python code in VSCode or PyCharm?

There is this code:

import urllib.request

resp = urllib.request.urlopen('https://google.ru')

print(resp)

I try to put a period after "resp" in the last line and press Ctrl + Space to see what properties and methods I can use, but nothing appears.
Screenshot from VSCode:
t0H4M.png
Screenshot from PyCharm:
HcIl7.png
If you write print(resp.headers), everything works fine, but as you can see, there is no headers property in the autocomplete hints. How to fix it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Tikhonov, 2019-03-14
@tumbler

Use type annotations until they are shipped to the IDE:

import urllib.request
from http.client import HTTPResponse

resp: HTTPResponse = urllib.request.urlopen("https://google.ru")

D
Drill, 2019-03-14
@Drill

Autocomplete and IntelliSense

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question