Python Function 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.

  • Unfold list

    Builds a list, using an iterator function and an initial seed value.

    Python, Function · Nov 2, 2020

  • List difference based on function

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

    Python, List · Nov 2, 2020

  • List intersection based on function

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

    Python, List · Nov 2, 2020

  • Tip: Watch out for mutable default arguments in Python

    Mutable default arguments can trip up Python beginners and veterans alike. Here's a quick workaround to deal with them.

    Python, Function · Feb 27, 2022

  • Reverse compose functions

    Performs left-to-right function composition.

    Python, Function · Nov 2, 2020

  • Compose functions

    Performs right-to-left function composition.

    Python, Function · Nov 2, 2020

  • Check property

    Creates a function that will invoke a predicate function for the specified property on a given dictionary.

    Python, Function · Nov 2, 2020

  • Curry function

    Curries a function.

    Python, Function · Nov 2, 2020

  • Apply function when true

    Tests a value, x, against a testing function, conditionally applying a function.

    Python, Function · Nov 9, 2020

  • Delayed function execution

    Invokes the provided function after ms milliseconds.

    Python, Function · Nov 2, 2020