If I know my dictionaries will always have a single element, is there a way to extract the key name without going through a list? I\'m currently doing it this way.
Use iterkeys:
iterkeys
data.iterkeys().next() 'foo'
Presuming you are using python 2
python 2
For python2 or python 3
python2
python 3
k, = data.keys() print (k) 'foo'