Dictionary as Keyword Arguments

bfrederi brfredericks at gmail.com
Fri Dec 12 01:02:27 CET 2008


I was wondering if I had a dictionary of keywords and values like so:

keyword_arg_dict = {
    'attribute': 'stone',
    'contents': 'cave people',
    'path': '/path/to/cave',
    'name': 'Ogg's Cave',
    }

And I had a function that accepted keyword arguments like so:

make_dwelling(
    attribute='stone',
    contents='cave people',
    path='/path/to/cave',
    name='Ogg's Cave',
    )

Is there any way I could use my keyword_arg_dict as my keyword args
for the make_dwelling function, since I am not the creator of the
make_dwelling function, and need to take that dictionary of key-value
pairs and turn it into keyword-value arguments for the make_dwelling
function?



More information about the Python-list mailing list