Skip to main content

io.BytesIO that preserves bytes after close

Project description

Python package bytesbufio

bytesbufio provides BytesBufferIO - an io.BytesIO implementation whose value can be accessed after it has been closed

Installation

pip install bytesbufio

Usage

import io

from bytesbufio import BytesBufferIO

bytesbuf = BytesBufferIO()
with io.TextIOWrapper(bytesbuf, encoding='utf-8') as textout:
    textout.write("Hello world.")

text = bytesbuf.getvalue().decode('utf-8') # BytesIO would have raised an ValueError here 
print(text)

Related

License

Copyright (c) 2020 by Cornelius Buschka.

Apache License, Version 2.0

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

bytesbufio-1.0.2.tar.gz (2.1 kB view hashes)

Uploaded Source

Built Distribution

bytesbufio-1.0.2-py3-none-any.whl (2.2 kB view hashes)

Uploaded Python 3

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