def filter_pages(pages, pagenum, pagename):
if pagenum:<EOL><INDENT>try:<EOL><INDENT>pages = [list(pages)[pagenum - <NUM_LIT:1>]]<EOL><DEDENT>except IndexError:<EOL><INDENT>raise IndexError('<STR_LIT>' % pagenum)<EOL><DEDENT><DEDENT>if pagename:<EOL><INDENT>pages = [page for page in pages if page.name == pagename]<EOL>if pages == []:<EOL><INDENT>raise IndexError('<STR_LIT>' % pagename)<EOL><DEDENT><DEDENT>return pages<EOL>
Choices pages by pagenum and pagename