Tkinter

Function arguments

Function arguments

The parameters are different sorts of data that can be supplied to the function. In the parenthesis, the arguments are provided. We can pass as many arguments as we like, but a comma must separate them.

Call by reference in Python

In Python, calling a function via reference means sending the real value as an argument. All functions are reference-based, which means that any modifications made to the reference inside the function revert to the reference's original value.

Argumentation types:

1. Required arguments

In terms of needed arguments, these arguments must be supplied with the exact match of their locations in the function call and function definition at the time of function calling. The Python interpreter will display an error if one of the parameters is not provided in the function call or if the location of the arguments is modified.

2. Keyword arguments

We can use the keyword parameters to call the function in Python. We can pass the arguments in a random sequence using this type of function call.

The names of the arguments are used as keywords and are matched in the function definition and calling. If the values of the parameters are the same, they are copied into the function definition.

3. Default arguments

The arguments can be initialised during the function definition in Python. If the value of any of the arguments is not specified at the time of the function call, that argument can be initialised with the value stated in the definition.

4. Variable-length arguments

We may not know the quantity of arguments to be passed in advance in huge projects. Python allows us to specify comma-separated values internally processed as tuples at the function call in such situations. 

We can pass any number of arguments by utilising variable-length parameters. However, we define the variable-length argument using the *args (star) as *variable - name > in the function specification.