Skip to content

Commit

Permalink
clarify py eval/exec behavior (closes #434)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevengj committed Aug 21, 2017
1 parent 7eab67e commit 0550f89
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,8 @@ and also by providing more type information to the Julia compiler.
type-conversion). Unlike the `@pyimport` macro, this does not
define a Julia module and members cannot be accessed with `s.name`.

* `py"..."` evaluates `"..."` as a Python string and returns the result
* `py"..."` evaluates `"..."` as a Python string, equivalent to
Python's [`eval`](https://docs.python.org/2/library/functions.html#eval) function, and returns the result
converted to `PyAny`. Alternatively, `py"..."o` returns the raw `PyObject`
(which can then be manually converted if desired). You can interpolate
Julia variables and other expressions into the Python code with `$`,
Expand All @@ -355,7 +356,7 @@ and also by providing more type information to the Julia compiler.
If you use `py"""..."""` to pass a *multi-line* string, the string can
contain arbitrary Python code (not just a single expression) to be evaluated,
but the return value is `nothing`; this is useful e.g. to define pure-Python
functions. (If you define a Python global `g` in a multiline `py"""..."""`
functions, and is equivalent to Python's [`exec`](https://docs.python.org/2/reference/simple_stmts.html#exec) statement. (If you define a Python global `g` in a multiline `py"""..."""`
string, you can retrieve it in Julia by subsequently evaluating `py"g"`.)

* `pybuiltin(s)`: Look up `s` (a string or symbol) among the global Python
Expand Down

0 comments on commit 0550f89

Please sign in to comment.