I want to build a query for sunburnt(solr interface) using class inheritance and therefore adding key - value pairs together. The sunburnt interface takes keyword arguments. How can I transform a dict ({'type':'Event'}) into keyword arguments (type='Event')?
Asked
Active
Viewed 392 times
1 Answers
1
You can do this using dictionary unpacking:
dct = dict({'type':'Event'})
# equivalent to func(type='Event')
func(**dct)

Jonas Adler
- 10,365
- 5
- 46
- 73
-
2What is the point of `dict()`? `{'type':'Event'}` is already a dict. – Siyuan Ren Aug 01 '17 at 11:58
-
Copied OPs code for his sake. – Jonas Adler Aug 01 '17 at 12:01
-
@SiyuanRen: It was in the original question. Maybe ask them? (ie, ask teaforthecat at https://stackoverflow.com/questions/5710391/converting-python-dict-to-kwargs) – Arafangion Aug 01 '17 at 12:01