While working on the implementation of PEP 208, I discovered that __coerce__ has some surprising properties. Initially I implemented __coerce__ so that the numberic operation currently being performed was called on the values returned by __coerce__. This caused test_class to blow up due to code like this: class Test: def __coerce__(self, other): return (self, other) The 2.0 "solves" this by not calling __coerce__ again if the objects returned by __coerce__ are instances. This has the effect of making code like: class A: def __coerce__(self, other): return B(), other class B: def __coerce__(self, other): return 1, other A() + 1 fail to work in the expected way. The question is: how should __coerce__ work? One option is to leave it work the way it does in 2.0. Alternatively, I could change it so that if coerce returns (self, *) then __coerce__ is not called again. Neil
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4