[Python-ideas] divmod(): fallback to __floordiv__ and __mod__?

Chris Angelico rosuav at gmail.com
Sat Sep 17 18:14:36 EDT 2016


On Sun, Sep 18, 2016 at 8:06 AM, Ethan Furman <ethan at stoneleaf.us> wrote:
> Just like Python will use the defined __ne__ if
> it's present, or fall back to negating the result of __eq__ if __ne__ is
> not present, I see __divmod__ working the same way:
>
> - is __mod__ present? use it
> - is __floordiv__ present? use it
> - otherwise, use __divmod__ and return the needed piece
>
> I'm pretty sure __div__ should not fall back to __divmod__.

How does __mod__ fall back to __floordiv__? I'm lost.

ChrisA


More information about the Python-ideas mailing list