Skip to main content

Erlang port protocol

Project description

<nav class="contents" id="contents" role="doc-toc">



Project URLs:


The erlport Python library implements Erlang external term format and Erlang port protocol for easier integration Python and Erlang.

The library exports the following classes and functions:

  • Port(packet=1, use_stdio=False) - class implementing port which connects with the corresponding Erlang port. See open_port/2 for description of packet and use_stdio arguments.

  • Protocol() - class which simplifies creation of request-response protocols.

  • Atom(str) - class which represents an Erlang atom.

  • String(unicode) - class representing an Erlang string which also can be an array of integers.

  • decode(str) - function to convert binary data into a term.

  • encode(term) - function to convert a term into the external format.

  • IncompleteData - exception raised by decode() in case of incomplete input data.



  • Erlang >= R11B-4

  • Python >= 2.4

To install the library use easy_install from setuptools package like this:

$ easy_install erlport


See examples directory in the source distribution for additional examples.

For simple request-response protocol use Port and Protocol on the Python side like this:

from erlport import Port, Protocol

class HelloProtocol(Protocol):

    def handle_hello(self, name):
        return "Hello, %s" % name

if __name__ == "__main__":
    proto = HelloProtocol()

On the Erlang side function hello() can be called like this:


hello(Name) ->
    Port = open_port({spawn, "python"},
        [{packet, 1}, nouse_stdio, binary]),
    port_command(Port, term_to_binary({hello, Name})),
        {Port, {data, Data}} ->

Test it in the Erlang shell:

1> c(hello).
2> hello:hello("Bob").
"Hello, Bob"


Please report bugs, offer suggestions or feedback at:

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

erlport-0.3.tar.gz (9.6 kB view hashes)

Uploaded source

Built Distribution

erlport-0.3-py2.6.egg (12.2 kB view hashes)

Uploaded 2 6

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page