约 1,720,000 个结果
在新选项卡中打开链接
  1. typing — Support for type hints — Python 3.10.18 …

    The Python runtime does not enforce function and variable type annotations. They can be used by third party tools such as type checkers, IDEs, linters, etc. This module provides runtime …

  2. How should I use the Optional type hint? - Stack Overflow

    Optional[...] is a shorthand notation for Union[..., None], telling the type checker that either an object of the specific type is required, or None is required. ... stands for any valid type hint, …

  3. Type annotations — typing documentation

    The following grammar describes the allowed elements of type and annotation expressions: | <NotRequired> '[' annotation_expression ']' | <ReadOnly> '[' annotation_expression ']' | …

  4. PEP 604 – Allow writing union types as X | Y | peps.python.org

    This PEP proposes overloading the | operator on types to allow writing Union[X, Y] as X | Y, and allows it to appear in isinstance and issubclass calls. PEP 484 and PEP 526 propose a …

  5. Python | Type Hints | Codecademy

    From Python 3.10 onwards, PEP 604 introduces the | operator as a concise alternative to Union, simplifying syntax for type annotations. This is an example of a function using type hints: …

  6. Python Type Annotations Full Guide - docs

    If the dynamic typing is needed, use Union (pre-Python 3.10, imported from typing) or the pipe operator, | (Python 3.10+): from typing import Union # not required Python 3.10+. dynamic: …

  7. Python's PEP 484: Advanced Type Hints and Annotations

    Since Python 3.10, you can use the | operator: Specifies multiple possible types for a variable. Since Python 3.10, use | instead of Union: Used to define custom type names for readability. …

  8. Python 3.9 use OR | operator for Union types? - Stack Overflow

    Since Python version 3.10, Unions can be writte as X | Y which is equivalent to Union[X, Y]. Is there some way/workaround to easily use (or just ignore) the X | Y syntax on Python 3.9? I …

  9. Python 3.10Simplifies Unions in Type Annotations

    In Python 3.10, you no longer need to import Union at all. All the details are in PEP 604. The PEP allows you to replace it entirely with the | operator. Once you have done that, the code above …

  10. Type Annotation in Python | TDS Archive - Medium

    Type annotations — also known as type signatures — are used to indicate the datatypes of variables and input/outputs of functions and methods. In many languages, datatypes are …