Rupyex.Object (Rupyex v0.1.0)

Copy Markdown View Source

A Python object with no Elixir counterpart: a class instance, a function, a module, a generator...

Only its class name and repr() cross the boundary — the object itself stays in the interpreter, where it stays reachable under whatever name it is bound to. Work with it by name:

{:ok, %Rupyex.Object{class: "range_iterator"}} =
  Rupyex.eval(session, "counter = iter(range(3))

counter")

{:ok, 0} = Rupyex.call(session, "next", ["counter"]) # wrong: passes a string
{:ok, 0} = Rupyex.eval(session, "next(counter)")     # right: name it in Python

Passing an Rupyex.Object back into Python raises a TypeError: there is no object on the Elixir side to send.

Summary

Types

t()

@type t() :: %Rupyex.Object{class: String.t(), repr: String.t()}