Skip to content

pystrings for easy global scope evaluation #307

Open
@andrew-saydjari

Description

@andrew-saydjari

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions