*args and **kwargs in Python | Python for Absolute Beginners in English |#39

Опубликовано: 15 Октябрь 2024
на канале: CodeWithAnsh
9
0

1) *args

The special syntax *args in function definitions in python is used to pass a variable number of arguments to a function. It is used to pass a non-key worded, variable-length argument list.

The syntax is to use the symbol * to take in a variable number of arguments; by convention, it is often used with the word args.
What *args allows you to do is take in more arguments than the number of formal arguments that you previously defined. With *args, any number of extra arguments can be tacked on to your current formal parameters (including zero extra arguments).

2.)**kwargs

The special syntax **kwargs in function definitions in python is used to pass a keyworded, variable-length argument list. We use the name kwargs with the double star. The reason is because the double star allows us to pass through keyword arguments (and any number of them).

This video is part of Python for Absolute Beginners in English Playlist:    • Python for Absolute Beginnners in Eng...  

Connect with me on:
Facebook
LinkedIn
Github
Instagram