symmetryinvestments / autowrap

Wrap existing D code for use in Python, Excel, C#
BSD 3-Clause "New" or "Revised" License
80 stars 16 forks source link

Calling python function not expected to work? #274

Open DavidBriant opened 3 years ago

DavidBriant commented 3 years ago

Just wanted to confirm that there's no way to call python from D at the moment? E.g.

def test_funcs():
    from pyd import appends_to_fn_cb
    import pytest
    #  FIXME
    with pytest.raises(RuntimeError):
        assert appends_to_fn_cb(lambda x: str(x), 42, "post") == \
            "42post"
DavidBriant commented 3 years ago

Just if anyone else needs this, what I eventually did, as a temporary work around, was:

import deimos.python.abstract_ : PyObject_CallObject;
import deimos.python.object;

export PyObject* callFn(PyObject* fn, PyObject* args) {
    return PyObject_CallObject(fn, args);
}