[Python-ideas] struct.unpack should support open files
Cameron Simpson
cs at cskk.id.au
Thu Dec 27 00:06:46 EST 2018
On 27Dec2018 02:53, Anders Hovmöller <boxed at killingar.net> wrote:
>
>> And this is why I, personally, think augumenting struct.unpack and json.read and a myriad of other arbitrary methods to accept both file-like things and bytes is an open ended can of worms.
>>
>> And it is why I wrote myself my CornuCopyBuffer class (see my other post in this thread).
>
>Seems like that should be in the standard library then!
It is insufficiently used at present. The idea seems sound - a flexible
adapter of bytes sources providing easy methods to aid parsing - based
on how useful it has been to me. But it has rough edges and one needs to
convince others of its utility before entry into the stdlib.
So it is on PyPI for easy use.
If you're in the binary I/O/parsing space, pip install it (and
cs.binary, which utilises it) and see how they work for you. Complain to
me about poor semantics or bugs. And then we'll see how general purpose
it really is. The PyPI package pages for each have doco derived from the
module docstrings.
Cheers,
Cameron Simpson <cs at cskk.id.au>
More information about the Python-ideas
mailing list