def fileobj_name(f):
 if isinstance(f, string_types):
  return f
 elif isinstance(f, gzip.GzipFile):
  return fileobj_name(f.fileobj)
 elif hasattr(f, 'name'):
  return f.name
 elif hasattr(f, 'filename'):
  return f.filename
 elif hasattr(f, '__class__'):
  return str(f.__class__)
 else:
  return str(type(f))

def fileobj_name ( f ) : if isinstance ( f , string_types ) : return f elif isinstance ( f , gzip . GzipFile ) : return fileobj_name ( f . fileobj ) elif hasattr ( f , 'name' ) : return f . name elif hasattr ( f , 'filename' ) : return f . filename elif hasattr ( f , '__class__' ) : return str ( f . __class__ ) else : return str ( type ( f ) )
returns the name of file-like object f .