You may recall our earlier discussion of accessing object attributes using the dotted attribute notation: object.attribute. List methods are no different, using list.method([arguments]). We use the dotted notation to access the attribute (here it is a function), then use the function operators ( ( ) ) in a functional notation to invoke the methods.
Types that have methods generally have an attribute called object.__methods__ which name all the methods that are supported by that type. In our case for lists, list.__methods__ serves this purpose.
Following table demonstrates the methods used with lists :
|list.append(obj)||appends object obj to list|
|list.count(obj)||returns count of how many times obj occurs in list|
|list.extend(seq)||appends the contents of seq to list|
|list.index(obj)||returns the lowest index in list that obj appears|
|list.insert(index, obj)||inserts object obj into list at offset index|
|list.pop(obj=list[-1])||removes and returns last object or obj from list|
|list.remove(obj)||removes object obj from list|
|list.reverse()||reverses objects of list in place|
|list.sort([func])||sorts objects of list, use compare func if given|