I stumbled over nimpy and I think it is a fantastic project! I'm now trying to use nimpy to call a locally given python module in Nim.
The first thing I want to do is more basic: Modifying Python's sys.path. I though of doing this via the Python object in Nim. I have:
import nimpy
let sys = pyImport("sys")
sys.path.insert(0, ".")
However with this I get
"Error: expression 'newPyObjectConsumingRef(callMethodAux(getAttr(sys, "path"), "insert", [nimValueToPy(0), nimValueToPy(".")], []))' is of type 'PyObject' and has to be used (or discarded)"
So I assume the problem is: The Python object path can be accessed via the dot '.' from sys but then the Python method cannot be accessed via a further '.'.
How can I call methods on Python objects?
BTW, maybe I haven't found it yet, but is there beyond the README some API like doco for nimpy?
PS: I am using Nim1.3.5 if that makes a difference here.
It works when you add discard:
import nimpy
let sys = pyImport("sys")
discard sys.path.insert(0, ".")
The problem with the original code is that Nim does not allow return values to be implicitly discarded.
Try
discard sys.path.insert(0, ".")