+ 1
Args and kwargs
I am unable to understand use of args and kwargs in python.
3 Réponses
+ 3
*args is like a box that holds many things (positional arguments), and **kwargs is like a magical book where you can write down any information (keyword arguments) you want. They help make functions more flexible by allowing them to handle different numbers of arguments and keyword arguments.
+ 3
Vivek Maurya ,
we can not only use args for functions in codes, but also when running a python script from the *command line* (passing command-line arguments to the script).
these arguments can be accessed within the python code (by using modules like `sys` or `argparse`) and can be used to customize the behavior of the script, based on the provided input.