OrderedDict dictionary types support hyphens: https://docs.python.org/2/library/collections.html#ordereddict-objects
This seems to be a side effect of the implementation of OrderedDict. Note that key value pairs are actually passed as sets. I would argue that the OrderedDict implementation does not use the "key" passed in the set as the true dict key, thereby circumventing this problem.
Since this is a side effect of the implementation of OrderedDict, this may not be what you want to rely on. But it works.
from collections import OrderedDict my_dict = OrderedDict([ ('has-dash', 'has dash value'), ('no dash', 'no dash value') ]) print( 'has-dash: ' + my_dict['has-dash'] ) print( 'no dash: ' + my_dict['no dash'] )
Result:
has-dash: has dash value no dash: no dash value
source share