Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can not import Protocol from typing

I have fresh installed Python 3.7-32 on Windows 10.

I want to try Protocols python approach and I do next:

file test_protocols.py with only one row:

from typing import Protocol

then:

>python test_protocols.py

And I have next error message that is needed to be explained:

Traceback (most recent call last):
  File "test_protocols.py", line 1, in <module> 
    from typing import Protocol
ImportError: cannot import name 'Protocol' from 'typing' (C:\Programing\Python\Python37-32\lib\typing.py)

What do I do wrong?

Maybe I have read PEP-0544 wrong but from my point of view I do the same as it is documented.

like image 892
mad Avatar asked Jan 20 '19 08:01

mad


1 Answers

As of January 20, 2019, PEP 544's status is Draft. As far as I understand, it's not implemented in CPython yet.

UPD: it should work since Python 3.8, try updating.

like image 173
yeputons Avatar answered Sep 29 '22 18:09

yeputons