質問

I have a function call that looks like this:

a,b,c,x,y,z = generatevalues(q)

Its in a try block to catch the error but I also need to find out which value is missing. I can't clear the variables beforehand either. I'd also rather not merge the 6 variables inside the function into a list and pass it, but other than that is there a way of finding out which variable(s) are missing?

役に立ちましたか?

解決

values = tuple(generatevalues(q))
try:
    a, b, c, x, y, z = values
except ValueError as e:
    print(len(values)) # for example
    print(values)

To debug this function - it's a good time to learn about the debugger

values = tuple(generatevalues(q))
try:
    a, b, c, x, y, z = values
except ValueError as e:
    import pdb; pdb.set_trace()
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top