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

    Jan 17, 2013 · def foo() -> lambda hi: True: "function body" # not a type expressions Beside the first the others have no typing meaning; but it still is valid syntax to hide a lambda definition in the return …

  2. python - Differences between `class` and `def` - Stack Overflow

    What is the main difference between class and def in python? Can a class in python interact with django UI (buttons)?

  3. What is a DEF function for Python - Stack Overflow

    Sep 10, 2013 · I am new to coding Python and I just can't seem to understand what a Def function is! I have looked and read many tutorials on it and I still don't quite understand. Can somebody explain to …

  4. python - What does def main () -> None do? - Stack Overflow

    As is, it does absolutely nothing. It is a type annotation for the main function that simply states that this function returns None. Type annotations were introduced in Python 3.5 and are specified in PEP …

  5. oop - What do __init__ and self do in Python? - Stack Overflow

    Jul 8, 2017 · The __init__ method is roughly what represents a constructor in Python. When you call A() Python creates an object for you, and passes it as the first parameter to the __init__ method. Any …

  6. Why should we use -> in def __init__ (self, n) -> None:?

    Nov 20, 2020 · In python 3.5 appeared type annotation option. def __init__(self, n) -> None: means that __init__ should always return NoneType and it can be quite helpful if you accidentally return …

  7. Groovy: what's the purpose of "def" in "def x = 0"?

    Oct 9, 2008 · The def keyword can be removed, and this snippet would produce the same results. So what's the effect of the keyword def ?

  8. function - Can't use def keyword in build.gradle.kts --> error ...

    Sep 4, 2023 · The def keyword comes from the Groovy language. This language is used when writing any *.gradle script. And *.gradle.kts uses the Kotlin language, so you should use that language. The …

  9. How does Python know where the end of a function is?

    The three forms above show how the end of a function is defined syntactically. As for the semantics, in Python there are three ways to exit a function: Using the return statement. This works the same as in …

  10. python - Why use def main ()? - Stack Overflow

    Oct 28, 2010 · Variables inside def main are local, while those outside it are global. This may introduce a few bugs and unexpected behaviors. But, you are not required to write a main() function and call it …