What is the purpose and use of **kwargs?
What are the uses for `**kwargs` in Python? I know you can do an `objects.filter` on a table and pass in a `**kwargs` argument. Can I also do this for specifying time deltas i.e. `timedelta(hours = time1)`? How exactly does it work? Is it classes as 'unpacking'? Like `a,b=1,2`?
Zachary F.
answered 07/24/21
Basic Math, General Computer Skill, and Python3 Tutor
**kwargs is used for both packing named arguments into a dictionary and for unpacking a dictionary's key and value pairs into named arguments.
Still looking for help? Get the right answer, fast.
OR
Find an Online Tutor Now
Choose an expert and meet online.
No packages or subscriptions, pay only for the time you need.
¢
€
£
¥
‰
µ
·
•
§
¶
ß
‹
›
«
»
<
>
≤
≥
–
—
¯
‾
¤
¦
¨
¡
¿
ˆ
˜
°
−
±
÷
⁄
×
ƒ
∫
∑
∞
√
∼
≅
≈
≠
≡
∈
∉
∋
∏
∧
∨
¬
∩
∪
∂
∀
∃
∅
∇
∗
∝
∠
´
¸
ª
º
†
‡
À
Á
Â
Ã
Ä
Å
Æ
Ç
È
É
Ê
Ë
Ì
Í
Î
Ï
Ð
Ñ
Ò
Ó
Ô
Õ
Ö
Ø
Œ
Š
Ù
Ú
Û
Ü
Ý
Ÿ
Þ
à
á
â
ã
ä
å
æ
ç
è
é
ê
ë
ì
í
î
ï
ð
ñ
ò
ó
ô
õ
ö
ø
œ
š
ù
ú
û
ü
ý
þ
ÿ
Α
Β
Γ
Δ
Ε
Ζ
Η
Θ
Ι
Κ
Λ
Μ
Ν
Ξ
Ο
Π
Ρ
Σ
Τ
Υ
Φ
Χ
Ψ
Ω
α
β
γ
δ
ε
ζ
η
θ
ι
κ
λ
μ
ν
ξ
ο
π
ρ
ς
σ
τ
υ
φ
χ
ψ
ω
ℵ
ϖ
ℜ
ϒ
℘
ℑ
←
↑
→
↓
↔
↵
⇐
⇑
⇒
⇓
⇔
∴
⊂
⊃
⊄
⊆
⊇
⊕
⊗
⊥
⋅
⌈
⌉
⌊
⌋
〈
〉
◊