[Python-ideas] collections.abc.Stream

Bar Harel bzvi7919 at gmail.com
Fri Jun 17 18:21:28 EDT 2016


+1 although isn't io.IOBase already an ABC for file-like objects?

On Fri, Jun 17, 2016 at 5:38 PM Michael Selik <michael.selik at gmail.com>
wrote:

>
> On Fri, Jun 17, 2016, 2:01 AM Ram Rachum <ram at rachum.com> wrote:
>
>> Is there a way to check in Python whether an object is file-like? (Like
>> `open`, `StringIO`, etc.) I would think that an abc in collections.abc will
>> be the standard solution, like we have for so many other data types, but I
>> can't find one.
>>
>
> File-like means different things in different places. Some functions want
> the read method, others want readline.
>
> How about just trying to use the method and catching AttributeError?
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160617/16276d65/attachment.html>


More information about the Python-ideas mailing list