Before discussing *args and **kwargs, we should have a basic knowledge about types of arguments. In Python programming, there are two types of arguments that can be passed in a function. positional arguments keyword arguments Positional arguments are the one in which an order has to be followed while passing arguments. We have been dealing with them until now. We know how normal functions work with positional arguments, so now we will directly start exploring keyword arguments. But to understand them, we have to know about asterisk or more commonly known in Perl 6 and ruby as a splat operator. Asterisk is used in python as a mathematical symbol for multiplication, but in case of arguments, it refers to unpacking. The unpacking could be for a list, tuple, or a dictionary. We will discover more about it by defining *args and **kwargs. *args: args is a short form used for arguments. It is used to unpack an argument. In the case of *args, the argument could be a list or t...
Comments
Post a Comment