# Generic Type (TypeVar)

say it: **“TYP VAR”** **/taɪp vɑːr/** or **“juh-NAIR-ik TYP”** **/dʒəˈnɛrɪk taɪp/**

Lets code work with any type while keeping in and out types linked.

## What is a **generic type**?

A **generic type** lets a function or class work with any type while keeping the types linked: whatever type goes in is the type that comes out.

```python
from typing import TypeVar

T = TypeVar("T")

def first_in_line(queue: list[T]) -> T:
    return queue[0]

name = first_in_line(["Ana", "Ben"])   # tools know this is a str
```

Level: Freelancer · [More Python terms at this level](https://www.ask-codey.com/glossary?category=python&level=4)

Updated: November 17, 2026

Source: https://www.ask-codey.com/glossary/generic-type-typevar
