Pagination | Python | Codewars

preview_player
Показать описание
How to create a pagination helper class in Python
Рекомендации по теме
Комментарии
Автор

Mate, you are so funny and I like you a lot! I can tell that you are brilliant and your mind works faster than you can express your ideas about the code. Keep it up and thanks a lot, it was very beneficial for my coding journey.

lukasjocius
Автор

Great work here sir. You taught me alot already, there is a simple contribution I would love to add to this. Look at the page_index() method, for item_index == item_per_page, the wrong page_index value is gotten.
To correct this, I added a bit of logic to it,

bolooemmanuel
Автор

Hi man, thanks for taking the time to show us the code, but it would be nice and more interesting if you could show a little more line of reasoning and communicate more. I noticed that the last two methods of page_item_count and page_index were missing a bit of explanation, but anyway thanks for making the material available. Success!

ikkik
Автор

Can you please share the source code link in GitHub ??

muralidharabagati
Автор

def page_index(self, item_index):
if item_index in range(self.item_count()):
if item_index == self.items_per_page:
return item_index // self.items_per_page - 1
return (item_index // self.items_per_page)

bolooemmanuel
Автор

Great work here sir. You taught me alot already, there is a simple contribution I would love to add to this. Look at the page_index() method, for item_index == item_per_page, the wrong page_index value is gotten.
To correct this, I added a bit of logic to it,

bolooemmanuel
visit shbcf.ru