Avoid using bare except in Python
It's generally not a good idea to use bare except
clause in Python, but do you know why?
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.
It's generally not a good idea to use bare except
clause in Python, but do you know why?
Converts a date to its ISO-8601 representation.
Moves the specified amount of elements to the start of the list.
Reverses a list or a string.
Moves the specified amount of elements to the end of the list.
Returns the index of the element with the maximum value in a list.
Creates a flat list of all the keys in a flat dictionary.
Checks if two lists contain the same elements regardless of order.
Converts a date from its ISO-8601 representation.
Flattens a list of lists once.
Converts a dictionary to a list of tuples.
Learn the difference between two common ways to access values in Python dictionaries and level up your code today.
Removes falsy values from a list.
Here are two quick and elegant ways to check if a string is empty in Python.
Maps a number from one range to another range.
Checks if the provided function returns True
for at least one element in the list.
Checks if any element in values
is included in lst
.
Checks if all the elements in values
are included in lst
.
Creates a list of partial sums.
Generates a list of numbers in the arithmetic progression starting with the given positive integer and up to the specified limit.
Returns a flat list of all the values in a flat dictionary.
Returns a list with n
elements removed from the beginning.
Returns a list with n
elements removed from the end.
Returns all elements in a list except for the first one.