bcdev / jpy

A bi-directional Python-Java bridge used to embed Java in CPython or the other way round.
Apache License 2.0
187 stars 37 forks source link

how to call a constructor with **kvargs #124

Open seblb opened 6 years ago

seblb commented 6 years ago

Good morning,

I am trying to call a class constructor with a kvargs signature without much success. A regular signature without works fine.

class MyPlugin:
    def __init__(self, **kvargs):
        return;
PyObject plugInObj = plugInModule.callMethod(className, pyParameters);

but this yields:

Error in Python interpreter:
Type: <type 'exceptions.TypeError'>
Value: __init__() takes exactly 1 argument (2 given)
Line: <not available>
Namespace: <not available>
File: <not available>

Thank you! Seb

forman commented 6 years ago

Thanks @seblb. Unfortunately jpy cannot yet distinguish between a variable length argument

It would be definitely useful to have that, but I fear I won't find time to implement this soon.