Home > Software design >  Assigning "None" to a function that requires transfer parameters (Python)
Assigning "None" to a function that requires transfer parameters (Python)

Time:09-05

I'm struggling at assigning "None" values to all parameter of a function.

for i in range(18):
    sx.set_attribute(v{i}=None)

The attributes I want to fill with "None" are v0 -> v18 I'm only looking for the right syntax. If you know a better way to assign "None" values to vars that do not contain values, present it too.

CodePudding user response:

You can first create a dictionary with function parameters(v0 -> v18) as keys and value as None. Then use ** to unpack the dictionary as function arguments.

sx.set_attribute(**{f"v{i}": None for i in range(18)})
  • Related