About 330,000 results
Open links in new tab
  1. python - How do I define a function with optional arguments? - Stack ...

    How do I define a function with optional arguments? Asked 13 years, 9 months ago Modified 1 year, 5 months ago Viewed 1.2m times

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

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

  3. 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 …

  4. python - How can I define a mathematical function in SymPy? - Stack ...

    1 Have a look at SymPy: How to define variables for functions, integrals and polynomials. You can define it according to these two ways: a Python function with def as described above a Python …

  5. 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.

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

    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, opts= {}...

  7. python - How do I get ("return") a result (output) from a function? How ...

    The natural, simple, direct, explicit way to get information back from a function is to return it. Broadly speaking, the purpose of a function is to compute a value, and return signifies "this is the value we …

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

    May 26, 2018 · 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.

  9. python - How do I forward-declare a function to avoid `NameError`s for ...

    In python the statement globals()[function_name]() is the same as foo() if function_name = 'foo' for the reasons discussed above, since python must lookup each function before calling it. If one were to …

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

    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 of parameters, …