JuliaPy / JuliaPy/PyCall.jl

getindex(::PyObject, ::Union{Symbol, AbstractString}) should not call getproperty

Open
#820 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
1.5k
Forks
186
PR merge metrics
No merged PRs in 30d

Description

Sometimes the Python object that underlies your PyObject needs to be accessed with a slice-like notation with a string rather than dot notation. `dict`s would be one example, but since they're converted to Julia `Dict`s, they don't really highlight the issue. Here is where I'm running into it. Unfortunately I don't have a better example than this (this one requires having MATLAB installed to run):
```julia
julia> using PyCall
```
```julia
julia> py"""
import matlab.engine
eng = matlab.engine.start_matlab()
"""
```
```julia
julia> eng = py"eng"
PyObject
```
```julia
julia> py"""
eng.workspace['a'] = 0.0
"""
```
```julia
julia> eng.workspace
Name Size Bytes Class Attributes

a 1x1 8 double

PyObject
```
```julia
julia> eng.workspace["a"]
ERROR: KeyError: key "a" not found
...
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.