Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update online docs, explain that GenericAlias instances are not class…
…es at runtime
  • Loading branch information
AbduazizZiyodov committed May 6, 2025
commit fbaaa4e87348fa8b0b38c8eebc6b5a7b36a59480
9 changes: 9 additions & 0 deletions Doc/library/stdtypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5346,6 +5346,15 @@ creation::
>>> type(l)
<class 'list'>


Additionally, instances of ``GenericAlias`` are not considered to be classes at runtime, even though they behave like classes (e.g. they can be instantiated)::

>>> import inspect
>>> inspect.isclass(list[int])
False

This is true for :ref:`user-defined generics <user-defined-generics>` also.

Calling :func:`repr` or :func:`str` on a generic shows the parameterized type::

>>> repr(list[int])
Expand Down
Loading