max
builtin PTC-W0042page = max(page, 1)
instead of the unnecessary if block 921
922 items_per_page = 5
923 pages = math.ceil(len(data) / items_per_page)
924 if page < 1: 925 page = 1
926 page = min(pages, page)
927 start = (page - 1) * items_per_page
It is unnecessary to use an if
statement to check the maximum of two values and then assign the value to a name.
You can use the max
built-in do do this. It is straightforward and more readable.
Not preferred:
if value <= 10:
value = 10
Preferred:
value = max(value, 10)