Skip to main content

Python helper method to determine if a string contains another string.

def str_contains(needle, haystack):
    return needle in haystack


# Usage
if str_contains('usr', '/usr/local/bin'):
    print('match found.')