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 摘要。