How to include Python Modules in a D Program?

Jon SchaduwBlink at hotmail.com
Mon Sep 24 15:05:32 PDT 2007


What would be higher level than this?

I was hoping for something that would be easy to use and allow me to include 
all the python modules. Is there an example of some kind for python module 
you linked? I just import that in my D program and then link to all the 
modules?

What would be the best course of action for this many modules? Maybe write a 
module in D that used that python module and all it does is wrap the python 
modules to cleaner code? I looked briefly at the PyD site, but they tend to 
have examples showing how to include D modules into Python. :( Did I miss 
something?

Thanks for replying and taking an interest in helping me. :)

Oh, by the way, I use GDC on Linux. It is the latest GDC version. I am also 
using Python v2.5.x

"Bill Baxter"wrote in message...
> 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