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

Spencer Brown spencerb21 at live.com
Sat Sep 17 05:01:53 EDT 2016


Currently, calling divmod() on a class with __floordiv__ and __mod__ defined, but not __divmod__ raises a TypeError. Is there any reason why it doesn't fallback to (self // x, self % x)? The invariants described in the function documentation should still apply (with well behaved % and //). If divmod() doesn't make sense setting it to None should be permitted.

- Spencer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160917/fb28bc7f/attachment.html>


More information about the Python-ideas mailing list