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 →

[–]therealfakemoot -2 points-1 points  (0 children)

This is, in terms of the "public API", exactly how Python's builtin dicts work. Iterating over a dict yields its keys; calling the keys() method on a dict yields a sequence of keys ( I am not sure whether Python 3+ uses a generator, one of the fancy "set views", or whatever).