# Dict of NamedTuple

**URL:** https://discourse.julialang.org/t/dict-of-namedtuple/112836
**Category:** General Usage
**Tags:** question, namedtuple, dict
**Created:** [April 11, 2024, 3:58pm UTC](https://discourse.julialang.org/t/dict-of-namedtuple/112836 "2024-04-11T15:58:00Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![fdekerme](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fdekerme/32/43574_2.png) [@fdekerme](https://discourse.julialang.org/u/fdekerme)
#### Post date: [April 11, 2024, 3:58pm UTC](https://discourse.julialang.org/t/dict-of-namedtuple/112836/1 "2024-04-11T15:58:00Z")

</div>

Hello ! 😀  
I have a question about a behavior I don’t understand when I try to make a dictionary composed of `NamedTuple`. Each of these `NamedTuple` corresponds to a parameter set of a simulation.  
For example:

```julia
julia> d = Dict( "param1" => (a = 1, b = 2))
Dict{String, @NamedTuple{a::Int64, b::Int64}} with 1 entry:
  "param1" => (a = 1, b = 2)

julia> d.keys
16-element Vector{String}:
    "param1"
 #undef
 #undef
 #undef
 #undef
 #undef
 #undef
 #undef
 #undef
 #undef
 #undef
 #undef
 #undef
 #undef
 #undef
 #undef

```

I specify that I’m using Julia 1.10.2

Thanks !  
fdekerm

---

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [April 11, 2024, 4:03pm UTC](https://discourse.julialang.org/t/dict-of-namedtuple/112836/2 "2024-04-11T16:03:01Z")

</div>

> [@fdekerme](#):
>
> `julia> d.keys`

this is an internal field of Dict, you shouldn’t be using it, you should use `keys(d)`

---

<div class="post-metadata">

### Author: ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)
#### Post date: [April 11, 2024, 4:03pm UTC](https://discourse.julialang.org/t/dict-of-namedtuple/112836/3 "2024-04-11T16:03:07Z")

</div>

> [@fdekerme](#):
>
> `> d = Dict( "param1" => (a = 1, b = 2))`

use `keys(d)` _not `d.keys`_ and `values(d)` _not `d.values`_

---

<div class="post-metadata">

### Author: ![fdekerme](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fdekerme/32/43574_2.png) [@fdekerme](https://discourse.julialang.org/u/fdekerme)
#### Post date: [April 11, 2024, 4:07pm UTC](https://discourse.julialang.org/t/dict-of-namedtuple/112836/4 "2024-04-11T16:07:16Z")

</div>

😶 😶 😶

My bad, I’ve been spending too much time on Python lately. Sorry for the question …

---

<div class="post-metadata">

### Author: ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)
#### Post date: [April 11, 2024, 5:34pm UTC](https://discourse.julialang.org/t/dict-of-namedtuple/112836/5 "2024-04-11T17:34:56Z")

</div>

_ **no worries** _
