+ 1
What's the difference between a function and a method?
4 ответов
+ 4
DEFINITELY NOT, not the same!
Functions are used to do the same action for numerous objects or variables. Functions are just sets of instructions to be followed, like adding 2 numbers.
Method is usually tight to a certain object type to perform a certain action over this particular object. Methods allow you to change object's property, like reversing the order of list items in the List.
Functions and Methods are declared and used differently:
Function: def mySampleFunction (arg1, arg2):
Method: myList.reverse () if you have a list of something like myList = [1,2,3,4,5]
+ 1
as illustrated by eugene
- 1
both are same
- 2
yes both are same