About 5,390,000 results
Open links in new tab
  1. python - Set default value and type for parameter - Stack Overflow

    Jun 25, 2018 · When you set the default value of pk=0, you make its default value an int, but someone using your function could easily call. which would make pk of type str. If you …

  2. python - How do I add default parameters to functions when using type

    If you're using typing (introduced in Python 3.5) you can use typing.Optional, where Optional[X] is equivalent to Union[X, None]. It is used to signal that the explicit value of None is allowed . …

  3. python - Default arguments with *args and **kwargs - Stack Overflow

    Putting the default arg after *args in Python 3 makes it a "keyword-only" argument that can only be specified by name, not by position. If you want a keyword-only argument in Python 2, you …

  4. Default arguments in Python - GeeksforGeeks

    Sep 11, 2024 · Python allows function arguments to have default values. If the function is called without the argument, the argument gets its default value. Python has a different way of …

  5. PEP 696 – Type Defaults for Type Parameters | peps.python.org

    Sep 3, 2024 · This PEP introduces the concept of type defaults for type parameters, including TypeVar, ParamSpec, and TypeVarTuple, which act as defaults for type parameters for which …

  6. Python Function Arguments [4 Types] – PYnative

    Aug 2, 2022 · In Python, we have the following 4 types of function arguments. In a function, arguments can have default values. We assign default values to the argument using the ‘=’ …

  7. How to Use Default Function Arguments in Python? - Python

    Feb 10, 2025 · Learn how to use default function arguments in Python by setting default values in function definitions. Simplify function calls and enhance flexibility.

  8. How to specify default parameter types | LabEx

    Learn how to specify default parameter types in Python using type hints, annotations, and best practices for improving code readability and type safety.

  9. Python: Typing a function with default parameters

    Feb 17, 2024 · Python’s flexibility allows for combinations of types with default parameters, utilizing the Union type for arguments that can accept multiple types. Here’s how you can …

  10. Can I define both function's argument's default value and data type

    You can use like this. def boo(arg1, arg2, arg3: int = 10): .... You can find more information PEP 484's section on default argument values

  11. Some results have been removed