From Lazarus wiki
Revision as of 10:00, 7 September 2014 by Tangentstorm (talk | contribs) (added my example code)

Current home seems to be

From that page:

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:

  • Low-level access to the python API
  • High-level bi-directional interaction with Python
  • Access to Python objects using Delphi custom variants (VarPyth.pas)
  • Wrapping of Delphi objects for use in python scripts using RTTI (WrapDelphi.pas)

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.

The changelog indicates development was last active around Nov 2012.

(possibly?) related resources

notes from a user

I was able to get this working on FreeBSD without relying on lazarus design-time components:

// demo illustrating how to use python for delphi
// from plain fpc, without lazarus or anything.

program simplefpcdemo;
uses PythonEngine, dynlibs;

var eng : TPythonEngine;
  eng := TPythonEngine.Create(Nil);
  if eng.IsHandleValid then
      WriteLn(' evens: ', eng.EvalStringAsStr('[x*2 for x in range(10)]'));
      eng.ExecString('print "powers:", [x**2 for x in range(10)]');
  else writeln('invalid library handle!', dynlibs.GetLoadErrorStr);

The output:

    evens: [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]
   powers: [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]

My personal working copy (including a python wrapper for my terminal library) is @tangentstorm/py4d on github. - tangentstorm