www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Python <==> d call both ways example (with PyD and autowrap)?

reply mw <mingwu gmail.com> writes:
Hi,

I know with PyD, D can call Python, and with autowrap, Python can 
call a D .dll, I'm just wondering if someone can show an example 
that Python <==> d can call both ways? esp. show passing D 
objects to Python and then call its member function there, and 
vice versa.

Thanks.
Jun 22 2022
next sibling parent Marvin <marvin marvin.com> writes:
On Wednesday, 22 June 2022 at 16:02:00 UTC, mw wrote:
 Hi,

 I know with PyD, D can call Python, and with autowrap, Python 
 can call a D .dll, I'm just wondering if someone can show an 
 example that Python <==> d can call both ways? esp. show 
 passing D objects to Python and then call its member function 
 there, and vice versa.

 Thanks.
I would also really like an example. Because it would be great to use Python and D together.
Jun 22 2022
prev sibling next sibling parent reply Tejas <notrealemail gmail.com> writes:
On Wednesday, 22 June 2022 at 16:02:00 UTC, mw wrote:
 Hi,

 I know with PyD, D can call Python, and with autowrap, Python 
 can call a D .dll, I'm just wondering if someone can show an 
 example that Python <==> d can call both ways? esp. show 
 passing D objects to Python and then call its member function 
 there, and vice versa.

 Thanks.
IIRC the best you can do is embed a Python interpreter inside a D program https://pyd.readthedocs.io/en/latest/embed.html
Jun 22 2022
parent mw <mingwu gmail.com> writes:
On Thursday, 23 June 2022 at 02:35:25 UTC, Tejas wrote:


 IIRC the best you can do is embed a Python interpreter inside a 
 D program

 https://pyd.readthedocs.io/en/latest/embed.html
Thanks. I tried something like this: https://github.com/symmetryinvestments/autowrap/issues/314 Although there were some compilation errors, I was able to built a dll and run. Maybe that error message is not a real error.
Jun 22 2022
prev sibling parent Jordan Wilson <wilsonjord gmail.com> writes:
On Wednesday, 22 June 2022 at 16:02:00 UTC, mw wrote:
 Hi,

 I know with PyD, D can call Python, and with autowrap, Python 
 can call a D .dll, I'm just wondering if someone can show an 
 example that Python <==> d can call both ways? esp. show 
 passing D objects to Python and then call its member function 
 there, and vice versa.

 Thanks.
When I did something like this, I used this as my inspiration: https://github.com/ariovistus/pyd/tree/master/examples/testdll So, I used PyD to supply D objects and read Python data also. Thanks, Jordan
Jun 22 2022