Is there a more elegant/shorter way to conditionally add a key-value pair to a dictionary in python than this:
extra = {'foo': 'bar'}
if something is True:
extra['some'] = 'thing'
Is there a more elegant/shorter way to conditionally add a key-value pair to a dictionary in python than this:
extra = {'foo': 'bar'}
if something is True:
extra['some'] = 'thing'
How about using update()
extra = {'foo': 'bar'}
extra.update({'some': 'thing'})