Skip to main content

openfile is a trivial Python module that implements a single convenience function openfile(filename, mode="rt", **kwargs) wich delegates the real work to one of the following standard library functions:

  • gzip.open(filename, mode, **kwargs) if the file ends with suffix .gz;

  • bz2.open(filename, mode, **kwargs) if the file ends with suffix .bz2;

  • lzma.open(filename, mode, **kwargs) if the file ends with suffix .xz or .lzma;

  • open(filename, mode, **kwargs) if the file does not end with any suffix mentioned above.

If the filename is a single dash - then sys.stdin or sys.stdout is returned, depending on mode being r or w, respectively.

The following keyword arguments are used by openfile:

  • expanduser=True will cause openfile to call os.path.expanduser for filename.

  • expandvars=True will cause openfile to call os.path.expandvars for filename.

  • makedirs=True will cause openfile to call os.makedirs for the parent directory os.path.dirname(filename) if it does not exist and mode contains either "w" or "a".

All other keyword arguments passed to openfile will be passed down to the open functions listed above.

Metadata

Release files for openfile 0.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openfile 0.0.6
File Size Uploaded
openfile-0.0.6.tar.gz 2.1 kB Details

Release files / openfile-0.0.6.tar.gz

Download URL openfile-0.0.6.tar.gz
Size 2.1 kB
Tags Source
SHA-256 checksum
How to use checksums
8fc37fb3b94c8d8256480307afb550d50bfcd0bcecc14e2cd91fa3f695894b1a
BLAKE2b-256 checksum
How to use checksums
17d35ca4ba162e3a34ae95d70bb38cd59bd1de66baf4de5ab53724afa512efb8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.0.7

2 release files

This release

0.0.6 This release

1 release file

0.0.5

1 release file

0.0.3

1 release file

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page