JuliaPy / JuliaPy/PythonCall.jl

pystrings for easy global scope evaluation

Offen
#307 9 Kommentare 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
enhancement
Vorherrschende Sprache
Julia
Sterne
1.1k
Forks
86
Ø Merge
1 T. 22 Std.
Gemergte PRs (30 T.)
3

Beschreibung

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.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
julia, python
Bereich
backend
Issue-Typ
Feature
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.