# Kotlin : Extend python

**URL:** <https://discuss.kotlinlang.org/t/kotlin-extend-python/11319>\
**Category:** Uncategorized\
**Created:** [January 26, 2019, 3:46pm UTC](https://discuss.kotlinlang.org/t/kotlin-extend-python/11319 "2019-01-26T15:46:25Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ziadab](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@ziadab](https://discuss.kotlinlang.org/u/ziadab)\
**Post date:** [January 26, 2019, 3:46pm UTC](https://discuss.kotlinlang.org/t/kotlin-extend-python/11319/1 "2019-01-26T15:46:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![fvasco](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/fvasco/32/1961_2.png) [@fvasco](https://discuss.kotlinlang.org/u/fvasco)\
**Post date:** [January 26, 2019, 4:43pm UTC](https://discuss.kotlinlang.org/t/kotlin-extend-python/11319/2 "2019-01-26T16:43:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![darksnake](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/darksnake/32/2479_2.png) [@darksnake](https://discuss.kotlinlang.org/u/darksnake)\
**Post date:** [January 26, 2019, 7:58pm UTC](https://discuss.kotlinlang.org/t/kotlin-extend-python/11319/3 "2019-01-26T19:58:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![cretz](https://avatars.discourse-cdn.com/v4/letter/c/d2c977/32.png) [@cretz](https://discuss.kotlinlang.org/u/cretz)\
**Post date:** [January 28, 2019, 10:55am UTC](https://discuss.kotlinlang.org/t/kotlin-extend-python/11319/4 "2019-01-28T10:55:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ziadab](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@ziadab](https://discuss.kotlinlang.org/u/ziadab)\
**Post date:** [January 28, 2019, 3:55pm UTC](https://discuss.kotlinlang.org/t/kotlin-extend-python/11319/5 "2019-01-28T15:55:12Z")

</div>

Yes. I know it but never use it

---

<div class="post-metadata">

**Author:** ![ziadab](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@ziadab](https://discuss.kotlinlang.org/u/ziadab)\
**Post date:** [January 28, 2019, 3:55pm UTC](https://discuss.kotlinlang.org/t/kotlin-extend-python/11319/6 "2019-01-28T15:55:45Z")

</div>

Maybe I need to learn Jython

---

<div class="post-metadata">

**Author:** ![ziadab](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@ziadab](https://discuss.kotlinlang.org/u/ziadab)\
**Post date:** [January 28, 2019, 3:56pm UTC](https://discuss.kotlinlang.org/t/kotlin-extend-python/11319/7 "2019-01-28T15:56:16Z")

</div>

I mean write python code inside a kotlin class

---

<div class="post-metadata">

**Author:** ![tokayasurecah](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/tokayasurecah/32/11456_2.png) [@tokayasurecah](https://discuss.kotlinlang.org/u/tokayasurecah)\
**Post date:** [September 18, 2026, 8:12pm UTC](https://discuss.kotlinlang.org/t/kotlin-extend-python/11319/8 "2026-09-18T20:12:36Z")

</div>

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](https://discuss.kotlinlang.org/t/kotlin-and-python/31214) for most info
