def isatty(stream):
    """Check if a stream is attached to a console.

    Args:
        stream (:obj:`io.IOBase`):
            Stream to check.

    Returns:
        :obj:`bool`

    """
    return stream.isatty() if hasattr(stream, "isatty") else False