Skip to content

What is a type? #923

Answered by JelleZijlstra
amacfie asked this question in Q&A
Nov 4, 2021 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

"Type" can have two different plausible meanings:

  • A runtime type object, such as a user-defined class or a builtin type like int. At runtime you can check for these with isinstance(obj, type). In the type system they are represented as e.g. type[int] (or Type[int] in older versions). An instance of TypeVar is not a type in this definition.
  • Something that is valid as an annotation in the type system. That includes all runtime types, but also some other objects, such as TypeVars and special forms like Any. There is no runtime function that tells you whether something is valid as a type annotation.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@sobolevn
Comment options

Answer selected by hauntsaninja
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants