kuniga.me > Docs > Python Cheatsheet
Syntax for common tasks I run into often. Assumes Python 3.
Map over list
NOTE: filter and map can be combined into one.
Using default sorting:
Sorting using key function. For example, sort list of pairs by the second element:
Sorting by custom comparator:
Map over dictionary
Dictionaries are unordered sets, so you likely want to work with a list after sorting.
Map over set
Other Data Structures
Queue class is an advanced implementation that can be used for example in multi-thread applications. We can still use it as a plain queue data structure.