JuliaPy / JuliaPy/PythonCall.jl

pystrings for easy global scope evaluation

未關閉
#307 9 則留言 2 個 reaction 已指派 0 人 在 GitHub 檢視
enhancement
主要語言
Julia
星號
1.1k
分支
86
平均合併
1 天 22 小時
30 天內合併 PR
3

描述

A feature request to enable support for functionality mirroring PyCall's pystrings. It is very helpful when people are transitioning from python to Julia to be able to execute and grab the results of a few simple lines of code in global python scope. Currently, my hack at reproducing this behavior is below, but making this functionality easier to access (maybe just by making py"""...""" implement the following wrapping) would be appreciated.

In PyCall
py"""
from dustmaps.config import config
config.reset()
config['data_dir'] = '../../dustmaps/'
import dustmaps.sfd
dustmaps.sfd.fetch()
"""

Hack-y PythonCall:
pyexec("from dustmaps.config import config",Main)
pyexec("config.reset()",Main)
pyexec("config['data_dir'] = '../../dustmaps/'",Main)
pyexec("import dustmaps.sfd",Main)
pyexec("dustmaps.sfd.fetch()",Main)

I tried getting something like this working with @pyeval begin ... end, but It was not obvious how to make the scope persist etc... So something to make this easy (or well documented if it exists) would be lovely.

貢獻指南

這個儲存庫沒有索引到貢獻指南

研究方向

Start by reading the existing pyexec and @pyeval entry points and compare them with PyCall's pystrings behavior. Define how multiline Python should execute in a persistent global scope and how results are returned; the feature is done when the dustmaps-style sequence works without repeated pyexec calls.

由索引模型根據 Issue 內容生成。

評估

技術堆疊
julia, python
領域
backend
Issue 類型
功能
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。