[Python-ideas] collections.abc.Stream
Ram Rachum
ram at rachum.com
Fri Jun 17 20:36:36 EDT 2016
Thanks for the io.IOBase reference!
On Sat, Jun 18, 2016 at 1:21 AM, Bar Harel <bzvi7919 at gmail.com> wrote:
> +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/20160618/014cb568/attachment.html>
More information about the Python-ideas
mailing list