ariovistus / pyd

Interoperability between Python and D
MIT License
157 stars 32 forks source link

any example to create a Python object on the D side, and call that object's member function passing a D array? #139

Open mw66 opened 3 years ago

mw66 commented 3 years ago

Hi,

I'm looking for an example to create a Python object on the D side, and call that object's member function also from D side.

I.e the D side holds a Python object, and call its method, may also pass in parameters using a D variable.

Is this possible? I checked the /examples dir, but didn't find clue how to do this.

The closest is pydobject/example.d, but it only get a PydObject ints (as list), and loop on it.

Ah, I just saw:

    PydObject random = py_eval("Random()", "random");
    random.method("seed", 234);
    int randomInt = random.randrange(1, 100).to_d!int();
    PydObject otherInt = random.randrange(200, 250);

it can pass string, and int to the PydObject, how to pass a D-array to PydObject?

Thanks.