Python 3 coerce () equivalent
2 answers
The reason for the removal coerce()
in python 3 is that it is no longer up to date, see http://python3porting.com/differences.html#coerce-and-coerce
You are expected to be able to just use arithmetic operators without coercion, and you are expected to be explicit when formatting the output for display. This was the case with pep-3141 in 2007, which was already implemented in python 2.6, the oldest supported language version.
I would be tempted to be more combative than the accepted answer, saying that you really shouldn't try to do this. To rely on python versions that would break it would just hurt you in a different way.
+2
source to share