(stream)
Using the same logic as pyyaml to handle both string types and file types. All file objects do not necessarily
    have a `name` attribute, in that case we can only say the stream is a file.
Using the same logic as pyyaml to handle both string types and file types. All file objects do not necessarily
    have a `name` attribute, in that case we can only say the stream is a file.
Using the same logic as pyyaml to handle both string types and file types . All file objects do not necessarily have a name attribute in that case we can only say the stream is a file .
def get_stream_name(stream):
    """Using the same logic as pyyaml to handle both string types and file types. All file objects do not necessarily
    have a `name` attribute, in that case we can only say the stream is a file."""
    if isinstance(stream, string_types):
        return "<string>"
    elif hasattr(stream, 'name'):
        return realpath(stream.name)
    else:
        return "<file>"
def get_stream_name ( stream ) : if isinstance ( stream , string_types ) : return "<string>" elif hasattr ( stream , 'name' ) : return realpath ( stream . name ) else : return "<file>"