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.

  • Delayed function execution

    Invokes the provided function after ms milliseconds.

    Python, Function · Nov 2, 2020

  • Check for duplicates in list

    Checks if there are duplicate values in a flat list.

    Python, List · Nov 2, 2020

  • List head

    Returns the head of a list.

    Python, List · Sep 15, 2020

  • List without last element

    Returns all the elements of a list except the last one.

    Python, List · Nov 2, 2020

  • List intersection

    Returns a list of elements that exist in both lists.

    Python, List · Nov 2, 2020

  • List is contained in other list

    Checks if the elements of the first list are contained in the second one regardless of order.

    Python, List · Jan 7, 2021

  • Last list element

    Returns the last element in a list.

    Python, List · Nov 2, 2020

  • Palindrome

    Checks if the given string is a palindrome.

    Python, String · Nov 2, 2020

  • List union

    Returns every element that exists in any of the two lists once.

    Python, List · Nov 2, 2020

  • Add days to date

    Calculates the date of n days from the given date.

    Python, Date · Oct 28, 2020

  • Clamp number

    Clamps num within the inclusive range specified by the boundary values.

    Python, Math · Nov 2, 2020

  • Number in range

    Checks if the given number falls within the given range.

    Python, Math · Sep 15, 2020

  • Number is prime

    Checks if the provided integer is a prime number.

    Python, Math · Nov 2, 2020

  • Pad number

    Pads a given number to the specified length.

    Python, String · Nov 2, 2020

  • Byte size of string

    Returns the length of a string in bytes.

    Python, String · Nov 2, 2020