skillfed

in-place

In-place file processing

in-place v1.0.1 80.4K downloads/30d#14,292 on PyPI34
Permissive license MIT Active released

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-place

uv

uv add in-place

poetry

poetry add in-place

Installing 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

Intended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: System :: FilesystemsTopic :: Text Processing :: FiltersTyping :: Typed

Tags

in-place file editingread and write same filetemporary file handlingfile modification in placesed-like file processingbackup file creationatomic file replacement
file-ioin-place-editingtempfile-wrapper

More Filters packages