First page Back Continue Last page Overview Graphics

Exercise

Change the factorial module so that factorial.fact(n) will return a tuple (n, fact(n)),

i.e.

>>> import factorial

>>> factorial.fact(6)

(6, 720)

>>>

Solution:

All we have to do is change the last line of the wrap_fact() function from

return Py_BuildValue("i", n, result);

into

return Py_BuildValue("(n, i)", n, result);