Can keyword arguments be variables? [duplicate]

1 week ago 16
ARTICLE AD BOX

I have a class that is initialized with a **kwargs parameter:

class Test: def __init__(self, measurement, data, **kwargs): # some stuff names = list(kwargs.keys()) settings = list(kwargs.values())

When I go to create an object, I want to pass in some other parameters as well:

test_obj = Test('meas1', data, param1=setting1,....)

I want to have "param1" be a variable and not be 'param1' when it gets unpacked, but python does not seem to allow that. It's treating "param1" as some kind of keyword.

Is there a workaround?

Read Entire Article