Using dot syntax and Symbols from Python

I’d use seval to create an anonymous function to do the broadcasting, like so:

f = jl.seval("x->JuMP.value.(x)")
v = jl.Symbol("myvariable")
f(model.ext[v])

This way the function f (and symbol v) can be computed once, but called many times.

Creating an anonymous function like this is a good way to access Julia semantics (such as broadcasting or macros) not otherwise exposed by JuliaCall.

2 Likes