JuliaPy / JuliaPy/PyCall.jl

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

Abierto
#820 1 comentario 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Julia
Estrellas
1.5k
Forks
186
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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
...
```

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Línea de trabajo

Start by locating the getindex(::PyObject, ::Union{Symbol, AbstractString}) implementation and reproduce the reported eng.workspace["a"] failure if MATLAB is available. Done means string indexing accesses the underlying Python object correctly instead of following getproperty and no longer raises KeyError for the shown example.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
julia, python
Área
backend-api-design
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.