Mark Dickinson <dicki...@gmail.com> added the comment:

I can't recall where I saw this originally, but you can use the spaceship 
operator "--0--" to turn floor division into ceiling division:

>>> 12//5
2
>>> --0-- 12//5
3

There's also the ++0++ operator when you want to emphasize that you really *do* 
mean floor division:

>>> ++0++ 12//5
2

But yes, -(-n // d) is the easy (if a little bit cryptic) way to get the 
ceiling of n / d.

----------
nosy: +mark.dickinson

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue43255>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to