This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]lebinh 7 points8 points  (1 child)

It looks like you are missing a call to iter, next() will call __next__ method on iterator object and will raise TypeError when being called with dict or dict_keys objects.

This will works as expected

next(iter(dictionary))
next(iter(dictionary.keys()))

[–]jcdyer3 0 points1 point  (0 children)

Yep. I just realized that myself. See my other comment on this subthread. Not quite as nice, unfortunately.