API Reference
WikiBook.getPageName( index )
Parameters:
| index | a zero-based index of the page name to be retrieved |
Returns: a string containing the page name.
Remarks:
There are two ways of obtaining a page name. To demonstrate the difference, here are two alternate methods of listing all
the page names within a book:
Method 1:
for i in range( numPages ): pageName = book.getPageName( i )
Method 2:
for i in range( numPages ): page = book.getPage( i ) pageName = page.getName()
While these produce the same result, there is a significant difference in performance. Method 1 is much faster than method
2. This is because when you create a book object, it immediately contains all of the page names. So method 1 requires the
book to simply access an array element from RAM.
Method 2, however, creates a page object for each page. This means a file has to be read from the disk, and a lot of initialization
has to be done on the page object, before you can query its name.
So which method to use? If you need to create the page object for other reasons anyway, you may as well use WikiPage.getName().
But if you can avoid creating the page object, it's preferable to use WikiBook.getPageName().
See Also: