About 26,400,000 results
Open links in new tab
  1. How do I call a function from another .py file? [duplicate]

    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 …

  2. What is the purpose of the `self` parameter? Why is it needed?

    For a language-agnostic consideration of the design decision, see What is the advantage of having this/self pointer mandatory explicit?. To close debugging questions where OP omitted a …

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

  4. Explaining Python's '__enter__' and '__exit__' - Stack Overflow

    def __enter__(self): return self def __exit__(self, type, value, tb): self.stream.close() Here is the complete code.

  5. How can I change a global variable from within a function?

    def test(): global a a = a + 10 print(a) Using the global keyword just tells the test where to look for a. With the first method, you can't modify the global variable a, because you made a copy of it …

  6. How can I return two values from a function in Python?

    I would like to return two values from a function in two separate variables. What would you expect it to look like on the calling end? You can't write a = select_choice(); b = select_choice() …

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

    What does the @ symbol do in Python?What's the syntactic or practical benefit of having decorators here, instead of (for example) just calling something like app.route("/", hello) …

  8. Why am I getting a NoClassDefFoundError in Java?

    I am getting a NoClassDefFoundError when I run my Java application. What is typically the cause of this?

  9. 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)?

  10. Why do some functions have underscores - Stack Overflow

    The other respondents are correct in describing the double leading and trailing underscores as a naming convention for "special" or "magic" methods. While you can call these methods directly …