Python Snippets

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 everything you need to know about Python's slice notation with this handy guide.

  • map_dictionary

    Python, List

    Maps the values of a list to a dictionary using a function, where the key-value pairs consist of the original value as the key and the result of the function as the value.

  • shuffle

    Python, List

    Randomizes the order of the values of an list, returning a new list.

  • Learn everything you need to know about Python's slice assignment with this handy guide.

  • difference_by

    Python, List

    Returns the difference between two lists, after applying the provided function to each list element of both.

  • filter_non_unique

    Python, List

    Creates a list with the non-unique values filtered out.

  • filter_unique

    Python, List

    Creates a list with the unique values filtered out.

  • get

    Python, Dictionary

    Retrieves the value of the nested key indicated by the given selector list from a dictionary or list.

  • intersection_by

    Python, List

    Returns a list of elements that exist in both lists, after applying the provided function to each list element of both.

  • Returns the symmetric difference between two lists, after applying the provided function to each list element of both.

  • union_by

    Python, List

    Returns every element that exists in any of the two lists once, after applying the provided function to each element of both.

  • Learn 3 easy ways to swap the values of two variables in Python.

  • find_index

    Python, List

    Finds the index of the first element in the given list that satisfies the provided testing function.

  • find_index_of_all

    Python, List

    Finds the indexes of all elements in the given list that satisfy the provided testing function.

  • Python provides two distinct comparison operators for different task. Stop mixing them up using this quick guide.