Communicating with python

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By RJGJ

Can Godot get a function or get a variable from a python script?

:bust_in_silhouette: Reply From: Zylann

Python is not a natively-supported language in Godot. There are ways to communicate with it but it will be harder than using GDScript, C or C#.

I wrote a similar answer in an older post: How can I use godot as machine learning environment - Archive - Godot Forum

Either use the Python binding made by TouilleMan, or use a system call to invoke the script (like a shell command would do), use C# to embed IronPython, or make your python system run on its own and communicate with network socket.

Note that if your code involves library dependencies, some of these solutions won’t work if their python runtime doesn’t have access to them.