Raymond Hettinger <raymond.hettin...@gmail.com> added the comment:
I think this may fine as-is. In general, virtiual classes only promise that an operation will work rather than promsing the presence of a particular method. An object can be Iterable without defining __iter__ because iter() can use __getitem__ and __len__ to build a sequence iterator. Likewise, an object can be a Container without defining __contains__ because the in-operator will work on any iterable. An object can be Reversible without defining __reversed__ because reversed() will fall back to an implementation based on __getitem__ and __len__. The docstring in numbers.Complex promises, "Complex defines the operations that work on the builtin complex type. In short, those are: a conversion to complex, .real, .imag, +, -, *, /, **, abs(), .conjugate, ==, and !=." In other words, the promise is that these work (which they do): >>> complex(0.0) 0j >>> int(0.0) 0 ---------- nosy: +rhettinger _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue47083> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com