I have a Twilio number and a dictionary full of params that I want to set up. The only way I know to set number properties is by passing them into the number.update()
function, so this is kinda annoying.
If the dictionary keys have the same name as the inputs I'm trying to pass to the update function, is there a cleaner way to do this?
or, can I do better than this?
params = {
'voice_url':'http://endpoint.co',
'friendly_name':'call a dinosaur'
}
number.update(voice_url=params['voice_url'], friendly_name=params['friendly_name']
Twilio developer evangelist here.
To do this you can use the unpacking operator **
like this:
number.update(**params)
**
unpacks a dictionary into keyword arguments.