{"categories":[{"label":"Python Modules","url":"https://skillfed.io/packages/category/software-development-libraries-python-modules/8"}],"enrichment":{"capability":"Returns the first true value from an iterable, with optional key function for custom selection logic and default fallback value.","skillfed_tags":["iteration-utility","functional-programming"],"use_cases":["Extract the first matching regex result from multiple compiled patterns without nested conditionals or repeated match calls.","Find the first non-empty or non-zero value in a sequence of candidates with a single readable function call.","Select the first element satisfying a custom condition (e.g., first even number) using a key function instead of filter + next.","Provide a fallback value when iterating through optional results that may all be falsy.","Simplify common patterns in data validation pipelines where you need the first valid or non-null result."],"what_it_does":"first is a minimal utility that extracts the first truthy value from an iterable, returning None (or a specified default) if no such value exists. It solves a common Python pattern that would otherwise require awkward constructs like next(filter(...)) or generator expressions with conditional logic.\n\nThe package provides a single function with three parameters: the iterable to search, an optional key function to customize how truthiness is evaluated (similar to how sorted() uses key), and an optional default to return when no true value is found. It has no dependencies and works across Python 2 and 3 implementations, making it a drop-in replacement for verbose iteration patterns, particularly useful in regex matching chains or filtering operations where readability matters.","worth_installing":"Yes. This is a stable, MIT-licensed utility with zero dependencies and low install friction. It solves a genuine readability problem in Python iteration patterns. Use it when you find yourself writing next(filter(...)) or generator comprehensions with conditionals\u2014first() is clearer and more Pythonic. The 2019 release date is not a concern given the code's simplicity and the active repository."},"id":"first","links":{"html":"https://skillfed.io/packages/first","md":"https://skillfed.io/packages/first.md","pypi":"https://pypi.org/project/first/"},"maintenance":{"status":"active"},"meta":{"latest_release":"2019-03-07","license_spdx":null,"license_treatment":"permissive","name":"first","python_support":"unspecified","summary":"Return the first true value of an iterable."},"popularity":{"monthly_downloads":785098,"position":5069,"tier":"top_15000"},"security":{"n_vulnerabilities":0},"version":"2.0.2"}
