Skip to content

Commit fbaaa4e

Browse files
Update online docs, explain that GenericAlias instances are not classes at runtime
1 parent 8325906 commit fbaaa4e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Doc/library/stdtypes.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5346,6 +5346,15 @@ creation::
53465346
>>> type(l)
53475347
<class 'list'>
53485348

5349+
5350+
Additionally, instances of ``GenericAlias`` are not considered to be classes at runtime, even though they behave like classes (e.g. they can be instantiated)::
5351+
5352+
>>> import inspect
5353+
>>> inspect.isclass(list[int])
5354+
False
5355+
5356+
This is true for :ref:`user-defined generics <user-defined-generics>` also.
5357+
53495358
Calling :func:`repr` or :func:`str` on a generic shows the parameterized type::
53505359

53515360
>>> repr(list[int])

0 commit comments

Comments
 (0)