in-place
In-place file processing
What it is and what it does
in_place is a single-class module that wraps the common pattern of reading a file, transforming its contents, and writing back to the same path. Instead of manually juggling temporary files, backups, and atomic renames, you pass a filename to InPlace and get a context manager that yields a read-write filehandle; data you write replaces the original file, and the module handles all the temporary file cleanup and safe replacement. It supports both text and binary modes, custom encodings, and optional backup creation (either by appending an extension or saving to a separate path).
Compared to Python's fileinput module, in_place returns a proper filehandle rather than hijacking sys.stdout, supports all standard I/O methods, allows full control over encoding and newline handling, and rolls back the original file if an exception occurs during processing. It's useful for command-line tools, log processors, configuration file editors, and any script that needs to safely modify files in place without risking data loss.
Use it for:
- Transform text files (e.g., remove vowels, convert case, apply regex substitutions) while preserving the original path.
- Process log files or configuration files with automatic backup creation for safety and auditability.
- Implement sed-like filtering in Python without manual temporary file and rename logic.
- Build command-line tools that modify files in-place with optional rollback on error.
- Edit binary files (e.g., patch headers, strip metadata) with atomic replacement and optional backup.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides an InPlace class for reading and writing files in-place, handling temporary file management and optional backups automatically.
Yes. Zero dependencies, permissive license, actively maintained, no known vulnerabilities, and solves a common file-handling problem cleanly. Use it whenever you need to safely read and write the same file without manual temporary file management.
Install
in-place on PyPI
pip
pip install in-placeuv
uv add in-placepoetry
poetry add in-placeInstalling in-place
Before you install
Low friction: pure Python wheel with no runtime dependencies. Actively maintained as of 2026-07-20 with support across Python 3.8 through 3.13 and PyPy.
License in practice
MIT license (permissive) — you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
import in_place
with in_place.InPlace("somefile.txt") as fp:
for line in fp:
fp.write(line.upper())
Requires Python 3.8 or higher.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 621 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 80,443/month — #14,292 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: in_place-1.0.1-py3-none-any.whl
Keywords: file, fileinput, in-place, inplace, io, open, redirection, sed, tempfile, tmpfile
Tags
More Filters packages
Pygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
MarkdownConverts Markdown text to HTML using a Python…
permissive · top 1,000 on PyPI
nltkNLTK is a Python library for natural language…
permissive · top 1,000 on PyPI
pandocfiltersProvides Python utilities for writing pandoc…
permissive · top 1,000 on PyPI
UnidecodeConverts Unicode text to ASCII-safe…
copyleft · top 1,000 on PyPI
pymdown-extensionsPymdown Extensions provides a collection of…
permissive · top 1,000 on PyPI
javapropertiesReads and writes Java .properties files in both…
permissive · top 5,000 on PyPI
bz2fileProvides a drop-in replacement for Python's…
permissive · top 15,000 on PyPI
file-read-backwardsReads files line-by-line from end to beginning…
permissive · top 15,000 on PyPI
editorOpens your system's default text editor (or a…
permissive · top 5,000 on PyPI
codemod-yamlModifies YAML documents in place with surgical…
permissive · top 15,000 on PyPI
gitmatchGitmatch implements gitignore-style pattern…
permissive · top 15,000 on PyPI
borgbackupBorgBackup is a command-line deduplicating…
permissive · top 15,000 on PyPI
memory-tempfileIdentifies and provides access to RAM-based…
permissive · top 15,000 on PyPI
atomicwritesProvides a context manager for writing files…
permissive · top 5,000 on PyPI
atomicwrites-homeassistantProvides atomic file writes that ensure a file…
permissive · top 15,000 on PyPI