Skip to content

cbuschka/python-bytesbufio

Repository files navigation

Python package bytesbufio

Sources Written in Python PyPI Build codecov License

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

About

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

Topics

Resources

License

Stars

Watchers

Forks