# Create a struct with keyward arguments

**URL:** <https://discourse.julialang.org/t/create-a-struct-with-keyward-arguments/18381>\
**Category:** New to Julia\
**Created:** [December 6, 2018, 3:36pm UTC](https://discourse.julialang.org/t/create-a-struct-with-keyward-arguments/18381 "2018-12-06T15:36:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cenwangumass](https://avatars.discourse-cdn.com/v4/letter/c/bb73d2/32.png) [@cenwangumass](https://discourse.julialang.org/u/cenwangumass)\
**Post date:** [December 6, 2018, 3:36pm UTC](https://discourse.julialang.org/t/create-a-struct-with-keyward-arguments/18381/1 "2018-12-06T15:36:24Z")

</div>

In Python, you can initialize a class with keyward arguments.

```julia
class A:
    def __init__ (self, a, b):
d = {‘a’: 1, ‘b’: 2}
a = A(**d)

```

Is this possible in Julia?

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [December 6, 2018, 3:44pm UTC](https://discourse.julialang.org/t/create-a-struct-with-keyward-arguments/18381/2 "2018-12-06T15:44:37Z")

</div>

You can use the Parameters.jl package:

```julia
julia> using Parameters

julia> @with_kw struct A
           a
           b
       end
A

julia> A(b = 2, a = 3)
A
  a: Int64 3
  b: Int64 2

julia> d = Dict(:b => 2, :a => 3);

julia> A(;d...)
A
  a: Int64 3
  b: Int64 2

```
