iterfzf
iterfzf is a Pythonic interface to fzf, a command-line fuzzy finder. It allows consuming iterables of strings and displaying them using fzf for interactive selection, returning the user's choice(s). Notably, it consumes iterables lazily, which is efficient for large or streamed inputs. The current version is 1.9.0.67.0, released on January 24, 2026, and bundles a prebuilt fzf binary for convenience. The library supports Python 3.8 and higher.
Warnings
- breaking Python 2.7, 3.5, 3.6, and 3.7 support was dropped in version 1.0.0.42.0 (released September 18, 2023). The library now officially supports Python 3.8 and higher.
- breaking All parameters to `iterfzf()` (except the initial `iterable`) became keyword-only in version 1.0.0.42.0. Passing options as positional arguments will now raise a TypeError.
- gotcha The input `iterable` must consist uniformly of either Unicode strings or byte strings; mixing these types will lead to `AttributeError` (e.g., `'tuple' object has no attribute 'encode'` if passing dictionary `items()` directly).
- gotcha If the user cancels the selection in the `fzf` interface (e.g., by pressing Escape), `iterfzf` raises a `KeywordInterrupt` exception. This exception is a subclass of `KeyboardInterrupt`.
- gotcha iterfzf does not follow standard Semantic Versioning. Its version string `X.Y.fzf_major.fzf_minor.fzf_patch` indicates `X.Y` as the library's own version and `fzf_major.fzf_minor.fzf_patch` as the bundled `fzf` binary's version.
Install
-
pip install iterfzf
Imports
- iterfzf
from iterfzf import iterfzf
- KeywordInterrupt
from iterfzf import KeywordInterrupt
Quickstart
from iterfzf import iterfzf, KeywordInterrupt
items = [
"apple",
"banana",
"cherry",
"date",
"elderberry",
"fig",
"grape",
]
try:
# Use multi=True to allow selecting multiple items
selected_items = iterfzf(
items,
multi=True,
header="Select fruits (Tab to multi-select, Enter to confirm, Esc to cancel):",
prompt=">> "
)
if selected_items:
print("You selected:", selected_items)
else:
print("No items selected.")
except KeywordInterrupt:
print("Selection cancelled by user.")
except Exception as e:
print(f"An error occurred: {e}")