Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Assigning "None" to a function that requires transfer parameters (Python)

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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)})
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading