functions vs methods

Sharan Basappa sharan.basappa at gmail.com
Sat Jul 21 15:06:08 EDT 2018


Is there a difference between functions and methods in Python.

For example, this is the text from tutorialpoint on Python:
Python includes the following list functions - cmp, len etc.

Python includes following list methods - append, count

A related question.

Refer to the following lines:
1) len(list) 
2) list.append()

The first line passes list to a len function while the second line calls append method in list.

So, how to interpret this?

In the first case, len is a function that python provides to which list can be passed and in the second case, append is a method within list class?

If my interpretation is correct, why not make len also as a part of list class itself?

Thanks in advance



More information about the Python-list mailing list