Skip to content

Trouble Converting Collections from Python to Julia #231

Closed
@mrufsvold

Description

@mrufsvold

I'm sure I'm just overlooking something in the docs, so I'm sorry for the redundant question!

I have a dictionary in Python that I'd like to pass into a Julia function. But it is getting converted to type PyCall.PyDict{Pycall.Py,Pycall.Py}. I tried to explicitly convert using PyCall.convert(Dict{String, Any}, my_python_dict) but it throws:

MethodError: Cannot `convert` an object of type PythonCall.Py to an object of type String

MWE:

from juliacall import Main as jl
d = {"a" : 1}
jl.typeof(d)
# <jl PythonCall.PyDict{PythonCall.Py, PythonCall.Py}>

Just to double check, I also tried jl.typeof("a") and got String back.

Any thoughts on how to get the dictionary into a Julia Dict?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions