def __getitem__(self, key):
        """Return immutable slice of pages with the square brackets syntax."""
        n = number_pages(self)
        if type(key) == int:
            page = key % n
            pages = {page}
        elif type(key) == slice:
            start, stop, step = key.indices(n)
            pages = set(range(start, stop, step))
        new_doc = keep_pages(self, pages)
        return new_doc
Return immutable slice of pages with the square brackets syntax.
pdfsyntax/docstruct.py