Kotlin : Extend python

Is there any possible way to write python code in kotlin code

No, but both can interoperate on Jvm, do you know Jython?

1 Like

In fact there are two ways. One can use JSR-223 to use Jython code as string inside Java/Kotlin code, and you can use GraalVM polyglot features.

In general, I would think twice before using either of those approaches.

I don’t understand the question part exactly, but based on the post title it should be noted that Kotlin Native can be used to write Python extensions just as you would in C/C++. There would be some effort into getting the C FFI right, but it’s doable.

Yes. I know it but never use it

Maybe I need to learn Jython

I mean write python code inside a kotlin class

the only way i have tried my level best is just the combination of fastapi framework as an api, python in the backend then kotlin has the frontend, the simplest way for beginners and just for very simple projects kotlin has a package called chaquopy , it helps to run python code in kotlin but for the big projects try the first option, visit Kotlin and Python for most info