{"library":"paginate","code":"from paginate import Page\n\n# A list of items to paginate\nall_items = list(range(1, 101)) # 100 items\n\n# Simulate current page number (e.g., from a URL query parameter)\ncurrent_page_number = 3\nitems_per_page = 10\n\n# Define a URL maker function for pagination links\ndef my_url_maker(page_num):\n    return f\"/items?page={page_num}\"\n\n# Create a Page object\npage = Page(\n    all_items,\n    page=current_page_number,\n    items_per_page=items_per_page,\n    url_maker=my_url_maker\n)\n\n# Access items for the current page\nprint(f\"Items on page {page.page}: {page.items}\")\n# Expected output for page 3 (items_per_page=10): [21, 22, ..., 30]\n\n# Get page information\nprint(f\"Total items: {page.item_count}\")\nprint(f\"Total pages: {page.page_count}\")\nprint(f\"Has previous page: {page.previous_page is not None}\")\nprint(f\"Has next page: {page.next_page is not None}\")\n\n# Generate a simple pager string (HTML representation)\n# For full customization, use page.link_map() with your templating engine.\npager_html = page.pager(\n    link_attr={'class':'pager_link'},\n    curpage_attr={'class':'pager_curpage'},\n    dotdot_attr={'class':'pager_dotdot'}\n)\nprint(\"\\nGenerated Pager (HTML, example output depends on page numbers):\\n\")\nprint(pager_html)\n\n# Example of using link_map for custom rendering\nprint(\"\\nLink Map for custom rendering (partial output):\")\nlink_info = page.link_map()\nfor k, v in list(link_info.items())[:3]: # Show first 3 for brevity\n    print(f\"  {k}: {v}\")\n","lang":"python","description":"This quickstart demonstrates how to paginate a simple list using the `Page` class. It shows how to initialize `Page` with a collection, current page, and items per page, and how to define a `url_maker` function. It then accesses the items for the current page and generates basic pagination links.","tag":null,"tag_description":null,"last_tested":"2026-04-24","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}