allow nested variable interpolation #381
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When I wrote #262, it relied on taking
py"..."
expressions inside of%julia
blocks and rewriting them to some custom code viamake_pyeval
which was basically a poorman's version ofPyCall.@py_str
(the code way basically copied from there in fact). The reason for this is becausePyCall.@py_str
didn't allow passing in a custom globals/locals dict, as is necessary for IPython magic.In JuliaPy/PyCall.jl#777, I've now made a way that you can pass these globals/locals (via a helper
PyCall.@_py_str
), so this PR removes my poorman's version and calls PyCall directly, so thesepy"..."
s aren't treated any differently than outside of%julia
blocks.Notably, and the reason for doing this, is that before you couldn't interpolate into
py"..."
s inside%julia
blocks, whereas now you can:This has come up a couple of times in my heavily interop'ed code and is nice to have, plus the lack of code duplication across pyjulia/PyCall is appealing.
What I don't know how best to do, and could use some guidance @tkf @stevengj is how best to make this backwards compatible here. Should I just have an
if PyCall.version < XXX
and then basically paste the entire contents of the newPyCall.@_py_str
, then just drop it in a (very) future version?Happy to take any other comments on this as well.