Could we leave this step to PyYAML:

~~~
>>> import yaml
>>> a = yaml.load('foo: foo\nbar: bar')
>>> a
{'foo': 'foo', 'bar': 'bar'}
>>> a.keys()
dict_keys(['foo', 'bar'])
~~~

**Note**: dictionaries `keys()` method have different behavior in Python2 and Python3.