About 50 results
Open links in new tab
  1. What's the difference between a method and a function?

    Oct 1, 2008 · A method is on an object or is static in class. A function is independent of any object (and outside of any class). For Java and C#, there are only methods. For C, there are only functions. For …

  2. In Python, when should I use a function instead of a method?

    The Zen of Python states that there should only be one way to do things- yet frequently I run into the problem of deciding when to use a function versus when to use a method. Let's take a trivial

  3. python - Class function vs method? - Stack Overflow

    Jan 27, 2023 · 2 Method is the correct term for a function in a class. Methods and functions are pretty similar to each other. The only difference is that a method is called with an object and has the …

  4. Python method vs function - Stack Overflow

    I am seeking for a confirmation if my thinking is correct in terms of Python method vs function: A method is a part of a class. A function is defined outside of a class. so e.g. class FooBar(ob...

  5. Difference between methods and functions, in Python compared to C++

    Does Python distinguish between methods and functions in the way C++ does? Unlike Difference between a method and a function, I'm asking about the particulars of Python. The terms 'method' and …

  6. python - When to us static methods vs. functions? - Stack Overflow

    Jun 25, 2020 · Somewhat of an opinion-based question, but in general, prefer a function unless you can make a strong argument for why your code would be improved by making a static method instead.

  7. Difference between methods and attributes in python

    Dec 24, 2022 · A function stored in an instance or class is called a method. According to Python's glossary: attribute: A value associated with an object which is referenced by name using dotted …

  8. python - Module function vs staticmethod vs classmethod vs no ...

    The idiomatic translation of a Java static method is usually a module-level function, not a classmethod or staticmethod. (And static final fields should translate to module-level constants.)

  9. What is the difference between @staticmethod and @classmethod in …

    Sep 26, 2008 · What is the difference between a method decorated with @staticmethod and one decorated with @classmethod?

  10. python - When should I use a class and when should I use a function ...

    Jul 4, 2012 · I'm intending on writing a script for Python which will parse different types of json data, and my gut feeling is that I should use a class to do this, versus a function.