'Append a new HDU to the `HDUList`.
Parameters
hdu : HDU object
HDU to add to the `HDUList`.'

def append(self, hdu):

    if (not isinstance(hdu, _BaseHDU)):
        raise ValueError('HDUList    can    only    append    an    HDU.')
    if (len(self) > 0):
        if isinstance(hdu, GroupsHDU):
            raise ValueError("Can't    append    a    GroupsHDU    to    a    non-empty    HDUList")
        if isinstance(hdu, PrimaryHDU):
            hdu = ImageHDU(hdu.data, hdu.header)
    elif (not isinstance(hdu, (PrimaryHDU, _NonstandardHDU))):
        if isinstance(hdu, ImageHDU):
            hdu = PrimaryHDU(hdu.data, hdu.header)
        else:
            phdu = PrimaryHDU()
            super(HDUList, self).append(phdu)
    super(HDUList, self).append(hdu)
    hdu._new = True
    self._resize = True
    self._truncate = False
    self.update_extend()
