Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to communicate with Erlang code from Python code?

Tags:

python

erlang

Let say I have Erlang "enterprise application":

-module(hello).
-export([start/0]).

start() ->
  spawn(fun() -> loop() end).

loop() ->
 receive
   hello ->
     io:format("Hello, World!~n"),
     loop();

   goodbye ->
     ok
 end.

Is there a way to run it from Python code? So that I can get the "Hello, World!" text back to Python? Erlport seems to work the other way around..

EDIT: In other words how to bind to an Erlang port from Python?

like image 748
mkorpela Avatar asked Dec 05 '25 01:12

mkorpela


1 Answers

What you are looking for is Py-Interface, it implements an Erlang compatible Node in Python.

The py_interface provides the possibility to create a node that may be used for communication with other Erlang nodes.

If you have a one-shot command line program that is written in Erlang and just want to execute it and capture the output, just use the subprocess module like you would with any other foreign executable.