About 50 results
Open links in new tab
  1. What does -> mean in Python function definitions?

    Jan 17, 2013 · 744 It's a function annotation. In more detail, Python 2.x has docstrings, which allow you to attach a metadata string to various types of object. This is amazingly handy, so Python 3 extends …

  2. Basic explanation of python functions - Stack Overflow

    Sep 5, 2015 · The same is true of the arguments in the function you've provided. This means that the order of the arguments in a function call is important. The Python language, like many others, …

  3. python - Python3 function definition, arrow and colon - Stack Overflow

    Feb 6, 2019 · The python interpreter does not do anything with this information in terms type checking, however the mypy interpreter will typecheck your code. For more information see PEP 484 and the …

  4. Invalid syntax error in Python - Stack Overflow

    Nov 23, 2013 · return x+2 function(5) In python, indentations are important. They are the {} of the python world. You actually do not need to add extra whitespace before function(5) because python knows …

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

    Aug 31, 2008 · In a function call the '*' unpacks data structure of tuple or list into positional or keyword arguments to be received by function definition. In a function call the '**' unpacks data structure of …

  6. How to know function return type and argument types?

    202 While I am aware of the duck-typing concept of Python, I sometimes struggle with the type of arguments of functions, or the type of the return value of the function. Now, if I wrote the function …

  7. What does the "at" (@) symbol do in Python? - Stack Overflow

    Decorators were added in Python to make (a function that receives a function and returns an enhanced one) easier to read and understand. The original use case was to be able to define the methods as …

  8. 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 3.8) …

  9. Syntax error when defining a function on the Python command line

    Jun 28, 2018 · "Essentially, this lets Python know that you are done defining your function." If you don't have the extra line, Python assumes you are still writing part of the function.

  10. python - Getting invalid syntax on function definition - Stack Overflow

    Jan 1, 2021 · Just tried your function definition in Python 3.7 and it works, no problem. I think you should double-check your environnement, you could be using a different version of Python unknowingly.