[Python-ideas] struct.unpack should support open files

Steven D'Aprano steve at pearwood.info
Wed Dec 26 06:25:06 EST 2018

On Wed, Dec 26, 2018 at 03:10:05AM -0800, Nathaniel Smith wrote:
> On Wed, Dec 26, 2018, 02:19 Andrew Svetlov <andrew.svetlov at gmail.com wrote:
> >
> > Also I'm thinking about type annotations in typeshed.
> > Now the type is Union[array[int], bytes, bytearray, memoryview]
> > Should it be Union[io.BinaryIO, array[int], bytes, bytearray, memoryview] ?
> >
> Yeah, trying to support both buffers and file-like objects in the same
> function seems like a clearly bad idea.

It might be clear to you, but it's not clear to me. Why is it a bad 
idea? The OP has a function which does precisely that, and it works well 
for him.


More information about the Python-ideas mailing list