Answer the question
In order to leave comments, you need to log in
How to work with a function with a large number of optional parameters?
I have a function with a lot of optional parameters
example
def fun(name="name", time=0, size=300, color="#fff"):
fun("name", 0, 300, "#ff0"):
def fun(arr):
name = ["name", "time", "size," "color"]
val = ["name", 0 , 300 , "#fff" ]
num = 0
for key in name :
try:
arr[key]
except KeyError:
arr[key] = val [num ]
Arr = {
"color"="#ff0"
}
fun(Arr)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question