This is baffling me:
row = {'Item1':1, 'Item2':2, 'Item3':3}
fieldnames = list(row.keys())
print(list(row))
fieldnames.append('Item4')
print(list(row))
Outputs
['Item3', 'Item1', 'Item2']
['Item3', 'Item1', 'Item2']
When run again:
['Item3', 'Item2', 'Item1']
['Item3', 'Item2', 'Item1']
What? Does keys() access the list randomly? Any better way of doing what I want? (i.e get the keys of a dict in the order they appear)