user401247
user401247

Reputation:

How to implement nested objects in Delphi for exposure with python4delphi?

Assume I have a class such as:

TArithmetic = class (TPersistent)
   function add (x, y : double) : double;
end;

and another class which I want to expose in python:

TMath = class (TPersistent)
  private
    FArithmetic : TArithmetic;
  public
    constructior Create; // Responsible for creating FArithmetic
  published
    property arithmetic : TArithmetic read FArithmetic; 
end;

So that I can do calls on the python side such as (assume they live in a module mylib):

import mylib
p = mylib.Math()
x = p.arithmetic.add (4, 5)

I know how to expose a simple class such as TArithmetic as an class in Python using Python4Delphi, that's straight forward. What I am not sure is how to register a class that has other classes within the parent class so that they are visible in Python.

Upvotes: 4

Views: 150

Answers (0)

Related Questions