+ 5
What's the difference between function & method in Python?
3 Answers
+ 9
Generally functions are performed ON objects, methods are performed BY objects.
Analogy example:
Function: wash a dog, repair a car, clean a room.
Method: a dog barks, a car moves, a goblin attacks.
Obviously a function can be a method (a boy washes a dog).
In real world "method" is just an OO (object-oriented) name for functions defined inside a class.
+ 8
Methods are basically functions that belong to classes.
- 4
methods are a part of functinos
to initialize (run) the method first we have to specify the function and then the method