开发者

How to export python functions and reuse them in another app

I was wondering if there is any way to export python functions to dll. There is py2exe and I can successfully create exe file. My program should be used by another program written in delphi (there is possibi开发者_JAVA百科lity of importing dll's in delphi).

So I was wondering what would be the best way to connect those 2 applications. Now I can only create exe, execute process in delphi and communicate in some way. But I don't think that's nice way. Maybe somebody have any experience in this subject?


There are some pretty big challenges to making languages work well together. As a simple alternative to trying to hook python code directly into delphi, you could consider using something like an xmlrpc server to provide python functionality remotely.

http://docs.python.org/library/xmlrpclib.html

Of course, any protocol could be used; xmlrpc just has some useful server utilities in python and presumably has a client library in delphi.


You can re-use python functions via modules. Integrating with other language is a different task all together.

py2exe packs all dependent modules and additional dlls required by an application so that it can be easily distributed without creating any installation dependencies for the user.

Cross - language integration requires some work. To integrate with "C", there are various ways like cython etc. If there is similar facility available with delphi, you might be able to use it.

Check out some of these references, it will make it more clear to you on what direction to take.

  • http://wiki.python.org/moin/IntegratingPythonWithOtherLanguages
  • http://www.atug.com/andypatterns/pythonDelphiTalk.htm
  • http://www.google.com/search?aq=f&sourceid=chrome&ie=UTF-8&q=python+delphi (Google search)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜