Message387264
The spaceship operator is kinda cool! :)
Well, I was hoping to avoid importing the math module just to have ceil division capabilities.
Anyway, my need for ceiling is that I am coding a chess GUI where I have a table with 2 columns and I create a new row whenever White makes a move. So, my implementation for row creation is math.ceil(len(moves) // 2) where moves is a list of chess moves.
So, the sequence of table rows after White and Black make their moves is initially 0 (since there are no moves yet) and then 1 (first row created after White made a move) and then 1 (again on row 1 after Black made a move, but on column 2), then 2 2 3 3 4 4 5 5 6 6 and so on.
If we had the ceil operator in Python, I could do: len(moves) /// 2 :)
By the way -- do you happen to know any better idea to get that kind of a sequence? That is 0 1 1 2 2 3 3 4 4 5 5 6 6 and so on. |
|
Date |
User |
Action |
Args |
2021-02-18 18:42:49 | PedanticHacker | set | recipients:
+ PedanticHacker, gvanrossum, rhettinger, mark.dickinson, vstinner, serhiy.storchaka |
2021-02-18 18:42:49 | PedanticHacker | set | messageid: <1613673769.08.0.400461050116.issue43255@roundup.psfhosted.org> |
2021-02-18 18:42:49 | PedanticHacker | link | issue43255 messages |
2021-02-18 18:42:48 | PedanticHacker | create | |
|