Question

I got this error: ValueError: need more than 2 values to unpack and was dumped out to a pdb prompt (actually, ipdb>). It happens that the computation was very expensive and I don't want to repeat it.

The function call looked like:

x,y,z = f(q)

Is there any way to recover what f(q) was going to return, given that I still have a live pdb session?

EDIT: to clarify, f(q) is extremely computationally expensive and cannot be repeated.

Était-ce utile?

La solution

>>> def func():x,y,z=f()
... 
>>> import dis
>>> dis.dis(func)
  1           0 LOAD_GLOBAL              0 (f)
              3 CALL_FUNCTION            0
              6 UNPACK_SEQUENCE          3
              9 STORE_FAST               0 (x)
             12 STORE_FAST               1 (y)
             15 STORE_FAST               2 (z)
             18 LOAD_CONST               0 (None)
             21 RETURN_VALUE 

Looking at how unpacking works it looks like the error is raised at UNPACK_SEQUENCE step, means before storing any value, so I guess you can't recover the returned values.

Autres conseils

You should be able to issue a simple print statement:

print f(q) 
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top