# How to access NamedTuple from JuliaCall?

**URL:** <https://discourse.julialang.org/t/how-to-access-namedtuple-from-juliacall/61043>\
**Category:** General Usage\
**Tags:** question, juliacall\
**Created:** [May 12, 2021, 7:58pm UTC](https://discourse.julialang.org/t/how-to-access-namedtuple-from-juliacall/61043 "2021-05-12T19:58:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mkarikom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkarikom/32/7096_2.png) [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Post date:** [May 12, 2021, 7:58pm UTC](https://discourse.julialang.org/t/how-to-access-namedtuple-from-juliacall/61043/1 "2021-05-12T19:58:55Z")

</div>

### background:

Suppose `myFunction` is a julia function that returns a named tuple.

I’ve been invoking `julia_call()` on `myFunction` as follows:

```julia-auto
output_list = julia_call("<julia module>.<myFunction>",<myFunction args>,need_return="R") 
Browse[1]> output_list[1]
[[1]]
Julia Object of type NamedTuple{(:thetahat, :Y), Tuple{Matrix{Float64}, Float64}}.
(thetahat = [0.013788374755447646 ...

```

### question

How can I access the named elements of `output_list` like `:Y` and `:thetahat` above?  
Please note, numeric index is not an option since `myFunction` will in general output a collection of varying size

---

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [April 2, 2023, 8:18pm UTC](https://discourse.julialang.org/t/how-to-access-namedtuple-from-juliacall/61043/2 "2023-04-02T20:18:42Z")

</div>

Hello, exactly the same here… have you found a solution ?

EDIT: found a way, but looks ugly:

```r
> eq = julia_call("nash_cp",payoff)
> eq
Julia Object of type NamedTuple{(:status, :equilibrium_strategies, :expected_payoffs), Tuple{MathOptInterface.TerminationStatusCode, Vector{Vector{Float64}}, Vector{Float64}}}.
(status = MathOptInterface.LOCALLY_SOLVED, equilibrium_strategies = [[0.0, 0.9999999887780999], [0.0, 0.9999999887780999]], expected_payoffs = [-1.9999999807790678, -1.9999999807790678])
> julia_call("getindex",eq,julia_call("Symbol","equilibrium_strategies"))
Julia Object of type Vector{Vector{Float64}}.
[[0.0, 0.9999999887780999], [0.0, 0.9999999887780999]]

```

EDIT2: A bit better:

```julia
> equilibrium_strategies = field(eq,"equilibrium_strategies")
> equilibrium_strategies
Julia Object of type Vector{Vector{Float64}}.
[[0.0, 0.9999999887780999], [0.0, 0.9999999887780999]]

```
