Skip to main content

Context manager to open encoded text file or stdin/stdout

Project description

Build Status License: Unlicense

Python 3 context manager to open a file or stdio. When reading in text mode, encoding can be detected with chardet. When reading Unicode, always chooses an encoding which removes Byte Order Mark (utf-8-sig, utf-16 or utf-32).

Additional arguments are passed to open().

Python writes a Byte Order Mark for utf-8-sig, utf-16, or utf-32. Python does not write BOM when endianness is specified.

Differences from open()

If file=None or '-', open stdin (when reading) or stdout (when writing).

If encoding=None and mode is readable and text mode ('r' or 'w+'), file encoding will be detected using chardet.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bom_open-0.4.tar.gz (3.1 kB view details)

Uploaded Source

File details

Details for the file bom_open-0.4.tar.gz.

File metadata

  • Download URL: bom_open-0.4.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8

File hashes

Hashes for bom_open-0.4.tar.gz
Algorithm Hash digest
SHA256 fad1a0ff4e1cc7c5d91ffcbaa98e4dd0131466ff88f3542c4052d17813ce8322
MD5 69ee68035138c80478a6d79b427b8e13
BLAKE2b-256 7ea704b8d3909c99af3a416fe1c637c2e91920abc599e6f701d88846503f0237

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page