{"id":10040,"library":"pipe","title":"Python Pipe Library","description":"The `pipe` library enables a shell-like infix syntax in Python, allowing users to chain operations on iterables using the pipe (`|`) operator. It provides a functional programming style for data processing, similar to LINQ in C# or shell pipes. The current stable version is 2.2, and it follows a slow but steady release cadence, focusing on stability given its utility nature.","status":"active","version":"2.2","language":"en","source_language":"en","source_url":"https://github.com/JulienPalard/Pipe","tags":["functional programming","pipeline","infix syntax","iterators","data processing"],"install":[{"cmd":"pip install pipe","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"select","correct":"from pipe import select"},{"symbol":"where","correct":"from pipe import where"},{"symbol":"take","correct":"from pipe import take"}],"quickstart":{"code":"from pipe import select, where, take\n\nl = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n# Chain operations: filter even numbers, double them, take the first 3\nresult = l | where(lambda x: x % 2 == 0) | select(lambda x: x * 2) | take(3)\n\n# The result is a generator; convert to list to see concrete values\nfinal_list = list(result)\n\nprint(final_list)","lang":"python","description":"This quickstart demonstrates chaining `where` (filter), `select` (map), and `take` (limit) operations on a list using the pipe syntax. It highlights that `pipe` operations are lazy and return generators, which must be explicitly consumed (e.g., by `list()`) to obtain concrete results."},"warnings":[{"fix":"Wrap the final piped result in `list()`, `tuple()`, `set()`, or iterate over it: `final_list = list(my_iterable | op1 | op2)`.","message":"Pipe operations are lazy and return generators. To get a concrete result (e.g., a list or a single value), you must explicitly consume the generator.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always use `my_list | function_name(...)` instead of `my_list | .function_name(...)` or `my_list.function_name(...)`. Ensure you import the specific functions.","message":"The `pipe` library functions (e.g., `select`, `where`) are standalone functions that receive the iterable via the pipe operator, not methods of the iterable itself.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure the left-hand side of each pipe operation (`|`) is an iterable. For single values, you might wrap them in a list or tuple: `[value] | select(...)`.","message":"Piped operations work on iterables. Passing a non-iterable (like an integer) as the initial input or at any point in the chain where an iterable is expected will raise a TypeError.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Add the necessary import statement: `from pipe import select` (or the specific function you are using).","cause":"Attempting to use a `pipe` function (like `select`, `where`, `take`) without explicitly importing it from the `pipe` module.","error":"NameError: name 'select' is not defined"},{"fix":"Ensure the initial object being piped is an iterable. If you have a single value, wrap it in a list: `[my_int] | select(...)`.","cause":"Trying to apply a pipe operation to a non-iterable object, such as an integer, instead of a list, tuple, or generator.","error":"TypeError: unsupported operand type(s) for |: 'int' and 'function'"},{"fix":"Call `list()`, `tuple()`, `set()`, `next()`, or iterate over the result to force evaluation: `final_data = list(initial_data | op1 | op2)`.","cause":"The `pipe` operations return generators, which are lazy. If you don't explicitly consume the generator, you won't see any concrete results or side effects.","error":"(No output/empty result when expected)"}]}