I have a function with a definite set of arguments, but that during development the amount of arguments it recieves could change. Each argument can either be a string, or a list. I want to someway loop trough the arguments of the function, and if they are a string, convert them to a list with that single element.
I tried using locals()
to be able to loop trough the arguments, but I don't know how to modify the value during the iteration, so I guess that's not the correct approach:
def function(a, b, c, d):
for key in locals():
if type(key) == str:
# ??? key = list(locals[key])
# ... more code over here, assuming that a,b,c,d are lists
What's the correct way to acomplish this?
Thanks!