About 125,000 results
Open links in new tab
  1. Generics — typing documentation

    Generics ¶ You may have seen type hints like list[str] or dict[str, int] in Python code. These types are interesting in that they are parametrised by other types! A list[str] isn’t just a list, it’s a list of strings. …

  2. Python Generics - GeeksforGeeks

    Oct 29, 2025 · Python generics are type hints in Python that allow you to write functions and classes that can work with any data type. In this article, we will discuss Python Generics with code examples.

  3. Generics - mypy 1.19.1 documentation - Read the Docs

    Python 3.12 introduced a new dedicated syntax for defining generic classes (and also functions and type aliases, which we will discuss later). The above example used the new syntax. Most examples are …

  4. The Complete Guide to Python Generics: From Beginner to Pro

    Aug 26, 2025 · Python Generics might sound intimidating, but they’re actually one of the most powerful features for writing clean, reusable, and type-safe code. Whether you’re using Python 3.8 or the latest...

  5. Python 3.12 Generics: Cleaner, Easier Type-Hinting - ArjanCodes

    Jun 6, 2024 · Learn how Python 3.12 generics make type-hinting easier and clearer. Use the new syntax to enhance your code's structure and readability.

  6. generic type | Python Glossary – Real Python

    In Python, a generic type is a type that you can parameterize with other types. For example, you can parameterize the dict type by doing something like dict[str, int]. This way, you communicate that the …

  7. Python - Generics - Online Tutorials Library

    In Python, generics is a mechanism with which you to define functions, classes, or methods that can operate on multiple types while maintaining type safety. With the implementation of Generics enable …

  8. 9. Generics - Thinking in Types

    Generics in Python produce flexible, reusable code that remains type-safe. They enable the definition of classes, functions, and types that can operate on a variety of types while preserving type information.

  9. Python Generic Types: A Comprehensive Guide - CodeRivers

    Apr 13, 2025 · Python generic types, introduced through the typing module, have enhanced the language's type hinting capabilities. They provide a way to write more flexible, reusable, and …

  10. Generics in Python - learnxbyexample.com

    Our example demonstrates the use of generic functions and types in Python. Python has supported generics since version 3.5 through type hinting, and more advanced generic features were …