Python 3.10 不这么认为:
Python 3.10.6 | packaged by conda-forge | (main, Aug 22 2022, 20:38:29) [Clang 13.0.1 ] \
on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from typing import Iterable
>>> isinstance(list[str], Iterable)
False
>>> list(list[str])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'types.GenericAlias' object is not iterable
Run Code Online (Sandbox Code Playgroud)
Python 3.11 认为它是:
Python 3.11.0 | packaged by conda-forge | (main, Jan 15 2023, 05:44:48) [Clang 14.0.6 ] \
on darwin
Type …Run Code Online (Sandbox Code Playgroud)