About 346,000 results
Open links in new tab
  1. 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 …

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

    Oct 28, 2010 · This means we can import that code into an interactive python shell and test/debug/run it. Variables inside def main are local, while those outside it are global.

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

    Jan 17, 2013 · 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 Python 3 extends the feature by …

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

    Jul 8, 2017 · a = A() # We do not pass any argument to the __init__ method a.method_a('Sailor!') # We only pass a single argument The __init__ method is roughly what represents a …

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

    I also do not know what to search for as searching Python docs or Google does not return relevant results when the @ symbol is included. If you want to have a rather complete view of …

  6. python - Why do some functions have underscores "__" before …

    May 24, 2024 · In Python, the use of an underscore in a function name indicates that the function is intended for internal use and should not be called directly by users. It is a convention used …

  7. python - What is the purpose of the return statement? How is it ...

    15 In python, we start defining a function with def, and generally - but not necessarily - end the function with return. Suppose we want a function that adds 2 to the input value x. In …

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

    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 484. Annotations for the …

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

    As for the semantics, in Python there are three ways to exit a function: Using the return statement. This works the same as in any other imperative programming language you may know. Using …

  10. Does the order of functions in a Python script matter?

    Jun 8, 2017 · The only thing that Python cares about is that the name is defined when it is actually looked up. That's all. In your case, this is just fine, order doesn't really matter since you are …