> Choosing between: > > list(d) or d.keys() > > Which is the one obvious way of turning a dictionary into a list? > IMO, list(d) is it. Ugh. I really hope we aren't going to teach people to write list(d) instead of d.keys(). The latter is totally clear. The former requires one to stop and remember that this uses the keys only. This is different for sets, where there's no ambiguity in what list(d) could possibly *mean* (except for the ordering, which is a second-order issue that doesn't affect the *type* of the result). While I *like* being able to write for key in d: ... instead of for key in d.keys(): ... I'm not so sure that having list(d) do anything at all was such a great idea. Not because of TOOWTDI, but because it doesn't tell the reader enough. And the polymorphism properties are really weird: if d could be either a mapping or a sequence, list(d) either loses information or it doesn't. --Guido van Rossum (home page: http://www.python.org/~guido/)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4