Python4Delphi: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: Python4Delphi
| Old | New | Line | |
|---|---|---|---|
| 1 | + | # Overview | |
| 2 | + | ||
| 3 | + | Current home: <https://code.google.com/p/python4delphi/> | |
| 4 | + | ||
| 5 | + | From that page: | |
| 6 | + | ||
| 7 | + | > Python for Delphi (P4D) is a set of free components that wrap up the Python dll into Delphi and Lazarus (FPC). They let you easily execute Python scripts, create new Python modules and new Python types. You can create Python extensions as dlls and much more. P4D provides different levels of functionality: | |
| 8 | + | > | |
| 9 | + | > - Low-level access to the python API | |
| 10 | + | > - High-level bi-directional interaction with Python | |
| 11 | + | > - Access to Python objects using Delphi custom variants (VarPyth.pas) | |
| 12 | + | > - Wrapping of Delphi objects for use in python scripts using RTTI (WrapDelphi.pas) | |
| 13 | + | > | |
| 14 | + | > P4D makes it very easy to use python as a scripting language for Delphi applications. It comes with an extensive range of demos and tutorials. | |
| 15 | + | ||
| 16 | + | The [changelog](https://code.google.com/p/python4delphi/source/list) indicates development was last active around Nov 2012. | |
| 17 | + | ||
| 18 | + | [The commit from 21.1.2018 claims the compatibility with both Lazarus and (hopefully) Delphi Linux](https://github.com/pyscripter/python4delphi/commit/88c06f11e70d471fc5dfd3b1e7e446c09eb5ab9a) | |
| 19 | + | ||
| 20 | + | # Lazarus port | |
| 21 | + | ||
| 22 | + | Lazarus port: [[Using Python in Lazarus on Windows/Linux]] | |
| 23 | + | ||
| 24 | + | # See also | |
| 25 | + | ||
| 26 | + | - Old wiki (~2006) with lots of examples at [py4d.pbworks.com](http://py4d.pbworks.com/w/page/9174525/FrontPage) | |
| 27 | + | - [Yahoo group](https://groups.yahoo.com/neo/groups/pythonfordelphi/info) | |
| 28 | + | - Notes from a [Python for Delphi talk](http://www.atug.com/andypatterns/pythonDelphiTalk.htm) | |
| 29 | + | ||
| 30 | + | # FreeBSD | |
| 31 | + | ||
| 32 | + | I was able to get this working on FreeBSD without relying on Lazarus design-time components: | |
| 33 | + | ||
| 34 | + | ``` pascal | |
| 35 | + | program simplefpcdemo; | |
| 36 | + | uses PythonEngine, dynlibs; | |
| 37 | + | ||
| 38 | + | var eng : TPythonEngine; | |
| 39 | + | begin | |
| 40 | + | eng := TPythonEngine.Create(Nil); | |
| 41 | + | eng.LoadDll; | |
| 42 | + | if eng.IsHandleValid then | |
| 43 | + | begin | |
| 44 | + | WriteLn(' evens: ', eng.EvalStringAsStr('[x*2 for x in range(10)]')); | |
| 45 | + | eng.ExecString('print "powers:", [x**2 for x in range(10)]'); | |
| 46 | + | end | |
| 47 | + | else writeln('invalid library handle!', dynlibs.GetLoadErrorStr); | |
| 48 | + | end. | |
| 49 | + | ``` | |
| 50 | + | ||
| 51 | + | The output: | |
| 52 | + | ||
| 53 | + | evens: [0, 2, 4, 6, 8, 10, 12, 14, 16, 18] | |
| 54 | + | powers: [0, 1, 4, 9, 16, 25, 36, 49, 64, 81] | |
| 55 | + | ||
| 56 | + | My personal working copy (including a Python wrapper for my terminal library) is <https://github.com/tangentstorm/py4d> . | |
| 57 | + | ||
| 58 | + | --- | |
| 59 | + | *From the Free Pascal wiki, page "Python4Delphi", as it stood on 2023-06-03 after a change by AMXS52, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* | |
| 60 | + | Category: FreeBSD | |
| 61 | + | Category: Linux | |
| 62 | + | Category: Other programming languages | |
| 63 | + | Category: Python | |
| 64 | + | Category: Windows |
