Python pipes Module
Note: The pipes module is Unix-only and has been deprecated , use subprocess instead.
Example
Create a simple pipeline (uppercase) and write to a file (Unix only):
# This only works on Unix systems and older Python versions (< 3.13)
import pipes
tmpl = pipes.Template()
tmpl.append('tr a-z A-Z', '--')
with tmpl.open('out.txt', 'w') as f:
f.write('hello')
Definition and Usage
The pipes module builds shell-style pipelines using a small Template helper.
Prefer the subprocess module for new code. pipes was platform-specific and limited.
Members
| Member | Description |
|---|---|
| Template | Represents a pipeline; create, clone, and reset command chains. |
| Template.append() | Add a command to the pipeline (with a file binding mode like '--'). |
| Template.clone() | Return a new pipeline template with the same commands. |
| Template.open() | Open a file object connected to the pipeline for reading/writing. |
| Template.reset() | Reset the template to its initial (empty) state. |