How to include Python Modules in a D Program?
Bill Baxter
dnewsgroup at billbaxter.com
Mon Sep 24 14:25:03 PDT 2007
Jon wrote:
> Hi,
>
> I am fairly new to D, and I would like to write a program that uses a
> bunch of modules that were written in Python. This is the reverse of
> what I have read where people use D written dlls in a python program. I
> have a lot of modules that would take too long to translate to D: a lot
> of files and several thousand lines of code each. So, it would be nice
> if I could use these modules with the D program. There are just some
> features of D that I want to use and I can only get away with these
> features if the program is a compiled program. Sometimes the python
> modules will not be used, for example, there is a safe mode that uses no
> external libraries at all in case something is broken, then you can at
> least start the program to back things up properly. The only way to do
> that is to have a compiled binary. Plus, I want to learn more about D
> application writing and not dll writing. :P I would appreciate it if
> someone could explain it very thoroughly.
>
> Thanks,
> Jon
There is a translation of the Python C/API. That should be all you need.
For general instructions on embedding python in a C application see:
http://www.python.org/doc/ext/embedding.html
For the D translation of the CPython API, see PyD (Specifically you need
this module
http://dsource.org/projects/pyd/browser/trunk/infrastructure/python/python.d)
Are you looking for something higher-level?
--bb
More information about the Digitalmars-d-learn
mailing list