About 132,000 results
Open links in new tab
  1. How can I specify the function type in my type hints?

    Jun 15, 2016 · How can I specify the type hint of a variable as a function type? There is no typing.Function, and I could not find anything in the relevant PEP, PEP 483.

  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. How do Python functions handle the types of parameters that you …

    Apr 7, 2017 · Python doesn't know that you are calling the function with the proper types, and expects the programmer to take care of that. If your function will be called with different types …

  4. python - How do I call a function from another .py file ... - Stack ...

    function(a, b) Note that file is one of Python's core modules, so I suggest you change the filename of file.py to something else. Note that if you're trying to import functions from a.py to a file …

  5. python - How do I add default parameters to functions when …

    If I have a function like this: def foo (name, opts= {}): pass And I want to add type hints to the parameters, how do I do it? The way I assumed gives me a syntax error: def foo (name: str, …

  6. What does -> mean in Python function definitions? - Stack Overflow

    Jan 17, 2013 · 743 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 …

  7. How can I define a mathematical function in SymPy?

    68 sympy.Function is for undefined functions. Like if f = Function('f') then f(x) remains unevaluated in expressions. If you want an actual function (like if you do f(1) it evaluates x**2 + 1 at x=1, …

  8. python - When to create a nested function inside a function and …

    Feb 16, 2021 · When to create a nested function inside a function and when to call it from outside? Asked 4 years, 9 months ago Modified 1 year, 4 months ago Viewed 13k times

  9. Define a method outside of class definition? - Stack Overflow

    You can define a function outside of a class and then add it. However, there is a subtle difference in assigning the function to the class or to the instance object.

  10. Python: defining a function inside of a function - Stack Overflow

    new_function = function_writer() new_function() In this case there doesn't seem to be much point (just as there wouldn't normally be much point defining a function that always returns 0), but if …