Skip to content

Commit e8fc01c

Browse files
committed
updated README.md
Signed-off-by: Cocoa <i@uwucocoa.moe>
1 parent 120a290 commit e8fc01c

1 file changed

Lines changed: 19 additions & 12 deletions

File tree

README.md

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,23 +81,30 @@ defmodule MyModule do
8181
import Pythonx
8282

8383
def do_stuff_in_python do
84-
pyeval(
85-
"""
86-
import math
87-
x = 5
88-
y = 6
89-
z = (x, y)
90-
x = math.pow(x, 2)
91-
""",
92-
return: [:x, :y, :z] # <- list of variables to return to Elixir
84+
a = 1
85+
b = 2
86+
pyinline("c = a + b",
87+
return: [:c]
9388
)
94-
95-
# these variables will be automatically defined in the current scope
96-
# {25, 6, {5, 6}} == {x, y, z}
89+
dbg(c)
9790
end
9891
end
9992
```
10093

94+
Or in IEx
95+
96+
```elixir
97+
iex> Pythonx.initialize_once()
98+
iex> import Pythonx
99+
iex> a = 1
100+
1
101+
iex> b = 2
102+
2
103+
iex> pyinline("c = a + b", return: [:c])
104+
iex> c
105+
3
106+
```
107+
101108
#### Executes a command with the embedded python3 executable
102109

103110
```elixir

0 commit comments

Comments
 (0)