def isstream(obj):
signature_methods = ("<STR_LIT>",)<EOL>alternative_methods = (<EOL>("<STR_LIT>", "<STR_LIT>", "<STR_LIT>"),<EOL>("<STR_LIT>", "<STR_LIT>", "<STR_LIT>"))<EOL>for m in signature_methods:<EOL><INDENT>if not hasmethod(obj, m):<EOL><INDENT>return False<EOL><DEDENT><DEDENT>alternative_results = [<EOL>numpy.all([hasmethod(obj, m) for m in alternatives])<EOL>for alternatives in alternative_methods]<EOL>return numpy.any(alternative_results)<EOL>
Detect if `obj` is a stream.

    We consider anything a stream that has the methods

    - ``close()``

    and either set of the following

    - ``read()``, ``readline()``, ``readlines()``
    - ``write()``, ``writeline()``, ``writelines()``

    :Arguments:
      *obj*
          stream or str

    :Returns:
      *bool*, ``True`` if `obj` is a stream, ``False`` otherwise

    .. SeeAlso::
       :mod:`io`


    .. versionadded:: 0.7.1