• + 0 comments

    the reason of * there is, it helps in passing the default value to the function so that the code can work.

    The syntax of of getattr is :- getattr(Object,function)(vars)

    As in this case our object is "L" and it doesn't contain the function passed in getattr, it will throw an error, so to avoid the error we are passing the default values of the function as mentioned in the question.

    Like for the case (insert 0 5) it is like getattr(l,insert)(0,5). We are passing 0 and 5 to insert so that it will add 5 at the index 0 in the list.