Tag: methods

Python: From Args to Kwargs

Posted in Python



In this short blog post, we talk about how and when you can take a method signature that defines input positional arguments by name, like this:

def foo(arg1, arg2, arg3):

and write code that will return a dictionary containing a keyword arguments-like structure:

>>> foo('red', 'blue', 'green')
    'arg1': 'red',
    'arg2': 'blue',
    'arg3': 'green'

We will cover an example of writing a decorator that utilizes input arguments from both the decorator and from the …

Tags:    python    programming    arguments    functions    methods    parameters