OpenQL does not work with pathlib
The OpenQL set and set_option methods do not work with pathlib duck typing for str. A minimal example:
import openql as ql
import tempfile
from pathlib import Path
output_dir = Path(tempfile.mkdtemp())
ql.initialize()
ql.set_option('output_dir', output_dir)
results in TypeError: in method 'set_option', argument 2 of type 'std::string const &'
Hello Pieter,
Thanks for reporting. It would indeed be nice for that to work.
The Python API of OpenQL is built with SWIG which makes it possible to call the C++ functions from within Python. C++ has obviously no knowledge of pathlib. And it seems that there is no implicit conversion to string done before calling the C++ method.
I would assume that doing the conversion yourself (with str(...)) works just fine?
Yes, conversion the str works fine. But this is something users will bump into, as pathlib is becoming more the standard, so it would be nice if openql could support this. Perhaps swig has options for this, but I have not checked