Honestly, this is definitely not the best idiom around, but I still find it useful.
If you ever find yourself writing the following code:
candidate = [x for x in iterable if "text" in x] |
you can use the following method to make the code a bit cleaner:
def get_first(iterable, predicate=None, default=None): |