# Jlwrap in PyJulia

**URL:** <https://discourse.julialang.org/t/jlwrap-in-pyjulia/28631>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [September 11, 2019, 2:52am UTC](https://discourse.julialang.org/t/jlwrap-in-pyjulia/28631 "2019-09-11T02:52:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![henry2004y](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henry2004y/32/9284_2.png) [@henry2004y](https://discourse.julialang.org/u/henry2004y)\
**Post date:** [September 11, 2019, 2:52am UTC](https://discourse.julialang.org/t/jlwrap-in-pyjulia/28631/1 "2019-09-11T02:52:16Z")

</div>

Hi there,

I have successfully installed PyJulia on Mac, and it seems to work smoothly. I wrote a data reader in Julia, and it can be correctly called from Python. The REPL in Python showed

```julia
<PyCall.jlwrap Main.VisAna.Data{Float32}(Float32[-127.5; -126.5; ......

```

However, when I tried to manipulate on the returned arrays from Julia function calls in Python, it showed me

```julia
data[1]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'PyCall.jlwrap' object is not subscriptable

```

I saw some relevant discussions in [PyCall issues](https://github.com/JuliaPy/PyCall.jl/issues/676), but got confused again.

My goal is to provide Python users a way to use data read from functions written in Julia. Is there an easy solution for me?

---

<div class="post-metadata">

**Author:** ![tkf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkf/32/17635_2.png) [@tkf](https://discourse.julialang.org/u/tkf)\
**Post date:** [September 11, 2019, 4:42am UTC](https://discourse.julialang.org/t/jlwrap-in-pyjulia/28631/2 "2019-09-11T04:42:06Z")

</div>

If you are OK with writing Python code and want to provide a Pythonic interface, the best option would be to create a Python class that wraps jlwrap. You can then call Julia functions inside the dunder methods like ` __getitem__ `. Look at how I did it in [PyBase.jl](https://github.com/tkf/PyBase.jl) as mentioned in the discussion you linked. Otherwise, you can also wait for [https://github.com/JuliaPy/PyCall.jl/issues/617](https://github.com/JuliaPy/PyCall.jl/issues/617).

---

<div class="post-metadata">

**Author:** ![henry2004y](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henry2004y/32/9284_2.png) [@henry2004y](https://discourse.julialang.org/u/henry2004y)\
**Post date:** [September 11, 2019, 1:54pm UTC](https://discourse.julialang.org/t/jlwrap-in-pyjulia/28631/3 "2019-09-11T13:54:50Z")

</div>

This is nice! Is there a way to use PyBase directly now? Say I am using Python 3.7 REPL. Now I understand why it doesn’t work before, but implementing a full Python class that wraps jlwrap object is a little bit excessive for me…

---

<div class="post-metadata">

**Author:** ![tkf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkf/32/17635_2.png) [@tkf](https://discourse.julialang.org/u/tkf)\
**Post date:** [September 11, 2019, 7:11pm UTC](https://discourse.julialang.org/t/jlwrap-in-pyjulia/28631/4 "2019-09-11T19:11:40Z")

</div>

You can install it via `pkg> add https://github.com/tkf/PyBase.jl` (type `]` in Julia REPL to get `pkg>` prompt). I haven’t tested it for a while so there may be a few trouble, though. If you want to fix some issues if any, use `dev` instead of `add`.
