<s>[INST] Python access to first element in dictionary If dict is not empty, the way I use to access first element in dict is:
dict[dict.keys()[0]]

Is there any better way to do this?
 [/INST] Non-destructively you can:
dict.itervalues().next()

On Python 3 this becomes
next (iter (dict.values()))

If you want it to work in both Python 2 & 3, you can use the six library:
six.next(six.itervalues(dict))

though at this point it is quite cryptic and I'd rather prefer your code.
If you want to remove any item, do:
key, value = dict.popitem()

Note that "first" is not an appropriate term here.  This is "any" item, because dict is not an ordered type.
 </s>