What does this mean: *args, **kwargs? And why would we use it?



What does this mean: *args, **kwargs? And why would we use it?..

Answer / Ankur Saxena

*args and **kwargs are special syntaxes used for variable-length arguments in Python functions. *args allows a function to accept any number of positional arguments as a tuple, while **kwargs allows a function to accept any number of keyword arguments as a dictionary. These are useful when the number or names of arguments passed to a function are not known at the time of defining the function.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Python Interview Questions

What is subclass in python?

1 Answers  


What are python templates?

1 Answers  


What is the python interactive console or python shell?

1 Answers  


When should you use the “break” in python?

1 Answers  


What is the difference between list and tuple?

1 Answers  


Why is epoch 1970?

1 Answers  


What is pytables?

1 Answers  


Why do computer scientists count from 0?

1 Answers  


What does “list comprehension” mean? How does it work and how can I use it?

1 Answers  


name few python modules for statistical, numerical and scientific computations?

1 Answers  


What is pypi repository?

1 Answers  


What are the generator functions in python?

1 Answers  


Categories