Hi! I am new to julia and I am trying to use julia in python because i need some python libraries.

I have some julia function that i would like to call using juliacall, but I got stuck when `[]`

was called on a zero-dimensional array and I don’t know how to do the same with juliacall, because it gives me syntax error.

Just to be precise: I have a short julia code `f(...)[]`

where the function f returns a zero-dimensional array. With juliacall I am calling jl.library_containg_the_function.f(…) and it works, but i don’t know how to use `[]`

.

Furthermore, I would like to not modify anything in the julia library.

Welcome. Indexing with square brackets is the syntax for calling the `getindex`

function. So you can replace `x[]`

with `getindex(x)`

, both in Julia itself and in juliacall.

3 Likes

Thank you so much for the reply! It solved my problem

1 Like

You can also do `x[()]`

in Python.

Why? Well `x[a,b,c]`

is just shorthand for `x[(a,b,c)]`

, i.e. indexing with a single tuple. This means that Python objects supporting “multi-indexing” actually just check if the given index is a tuple. Therefore you can do “empty-indexing” with the empty tuple.