About 20,100,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. 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.

  4. 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) …

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

  6. What should I do with "Unexpected indent" in Python?

    def my_function(): x = 3 y = 7 the interpreter will interpret the empty line before y = 7 as the end of the expression, i.e. that you're done defining your function, and the next line - y = 7 will have …

  7. 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() …

  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. Why am I getting "IndentationError: expected an indented block"?

    def foo(): if 1: print 1 Please note that before if, there is a tab, and before print there is 8 spaces. Output: File "<stdin>", line 3 print 1 ^ IndentationError: expected an indented block It's quite …

  10. How does the @property decorator work in Python? - Stack …

    I would like to understand how the built-in function property works. What confuses me is that property can also be used as a decorator, but it only takes arguments when used as a built-in …