'Construct a `HDUList` object.
Parameters
hdus : sequence of HDU objects or single HDU, optional
The HDU object(s) to comprise the `HDUList`.  Should be
instances of HDU classes like `ImageHDU` or `BinTableHDU`.
file : file object, bytes, optional
The opened physical file associated with the `HDUList`
or a bytes object containing the contents of the FITS
file.'

def __init__(self, hdus=[], file=None):

    if isinstance(file, bytes):
        self._data = file
        self._file = None
    else:
        self._file = file
        self._data = None
    self._save_backup = False
    self._open_kwargs = {}
    self._in_read_next_hdu = False
    if (file is None):
        self._read_all = True
    elif (self._file is not None):
        self._read_all = (self._file.mode == 'ostream')
    else:
        self._read_all = False
    if (hdus is None):
        hdus = []
    if isinstance(hdus, _ValidHDU):
        hdus = [hdus]
    elif (not isinstance(hdus, (HDUList, list))):
        raise TypeError('Invalid    input    for    HDUList.')
    for (idx, hdu) in enumerate(hdus):
        if (not isinstance(hdu, _BaseHDU)):
            raise TypeError('Element    {}    in    the    HDUList    input    is    not    an    HDU.'.format(idx))
    super(HDUList, self).__init__(hdus)
    if (file is None):
        self.update_extend()
