Python – something about function arguments

We have talked about briefly how to read in arguments from the command line using argparse from this post, however, do you know there is really a lot that you might not know about defining a function in Python. How to read optional argument, how to read in positional argument and also how the scope/namespace works. Those are all really interesting questions and you can check out this python documentation – Controlflow.

pythonargumentsThe example above show that an argument start with one start will read in the arguments sequentially and it doesn’t have to use the keyword args even if most people use *args all the time.

Second, **kwargs is short keyword arguments. As you can see, it will parse the function input as a dictionary and store the keyword along with its corresponding values in a dictionary.