About 102,000 results
Open links in new tab
  1. python - What do * (single star) and / (slash) do as independent ...

    Jan 9, 2020 · The function parameter syntax (/) is to indicate that some function parameters must be specified positionally and cannot be used as keyword arguments. (This is new in Python …

  2. python - How do I define a function with optional arguments?

    See the Python documentation for an excellent summary; the various other answers to the question make use of most of these variations. Since you always have parameters a, b, c in …

  3. python - How to get method parameter names? - Stack Overflow

    Jan 14, 2023 · In CPython, the number of arguments is a_method.func_code.co_argcount and their names are in the beginning of a_method.func_code.co_varnames These are …

  4. Passing functions with arguments to another function in Python?

    On the other hand, if perform is expected to be able to call its passed-in function without arguments, then arguments for the underlying action2 and action3 need to be bound ahead of …

  5. python - What does ** (double star/asterisk) and * (star/asterisk) …

    Aug 31, 2008 · The *args and **kwargs are common idioms to allow an arbitrary number of arguments to functions, as described in the section more on defining functions in the Python …

  6. python - Can a variable number of arguments be passed to a …

    May 28, 2009 · Since the question implies a variable number of items this answer is not really applicable. More generally you can mix a fixed number items passed by position and a …

  7. How do Python functions handle the types of parameters that you …

    Apr 7, 2017 · Unless I'm mistaken, creating a function in Python works like this: def my_func(param1, param2): # stuff However, you don't actually give the types of those …

  8. python - Normal arguments vs. keyword arguments - Stack Overflow

    Jan 3, 2024 · How are "keyword arguments" different from regular arguments? Can't all arguments be passed as name=value instead of using positional syntax?

  9. Pythonic way to write functions/methods with a lot of arguments

    Jan 28, 2019 · I think the 'Pythonic' way of answering this is to look deeper than syntax. Passing in that many arguments to a method indicates a likely problem with your object model. First of …

  10. python - Is it possible to declare a function without arguments but ...

    May 17, 2014 · The stack comment is besides the point. Python is stack-based, but argument passing (and parsing) is not (arguments are always a single item on the stack, even when …

Refresh