It took me ages to figure out why the following did not manage to add a conversion rule, despite it following the documentation here and here
const mylib = pynew()
function __init__()
pycopy!(mylib, pyimport("mylib")
pyconvert_add_rule(".......", T, _func)
end
It seems swapping the order solves the issue
const mylib = pynew()
function __init__()
pyconvert_add_rule(".......", T, _func)
pycopy!(mylib, pyimport("mylib")
end
i.e. the conversion rule must be added before pyimport is called. I guess it is too late to add the rules once the python executable has started? Perhaps this should be clarified in the documentation?
No that's a bug, you should be able to add rules at any point. What version of PythonCall are you on? Please post some complete reproducing code which demonstrates the issue.
Affects: PythonCall
Description:
It took me ages to figure out why the following did not manage to add a conversion rule, despite it following the documentation here and here
It seems swapping the order solves the issue
i.e. the conversion rule must be added before
pyimport
is called. I guess it is too late to add the rules once the python executable has started? Perhaps this should be clarified in the documentation?