The Python snippet collection contains helper functions for Python 3.6. It includes utilities for most common data types, such as primitivies, lists, dictionaries and date objects.
Learn the difference between Python's built-in list sorting methods and when one is preferred over the other.
Writing short, efficient Python code is not always straightforward. Read how we optimize our list snippets to increase performance using a couple of simple tricks.
Python, List
Merges two or more lists into a list of lists, combining elements from each of the input lists based on their positions.
Python, String
Python's f-strings can do a lot more than you might expect. Learn a few useful tips and tricks in this quick guide.
Python, Function
Mutable default arguments can trip up Python beginners and veterans alike. Here's a quick workaround to deal with them.
Python, Dictionary
Inverts a dictionary with non-unique hashable values.
Python, List
Groups the elements of a list based on the given function and returns the count of elements in each group.
Python, Date
Creates a list of dates between start
(inclusive) and end
(not inclusive).
Python, Dictionary
Combines two or more dictionaries, creating a list of values for each key.
Python, String
Converts a hexadecimal color code to a tuple of integers corresponding to its RGB components.
Python, List
Sorts one list based on another list containing the desired indexes.
Python, Function
Builds a list, using an iterator function and an initial seed value.
Python, List
Understand Python's named tuples and start using them in your projects today.
Python, List
Splits values into two groups, based on the result of the given filtering function.
Python, List
Creates a list with the non-unique values filtered out.