Coerce with new style classes
aleax at aleax.it
Mon Feb 24 09:33:49 CET 2003
Blair Hall wrote:
> I can't seem to use coerce with the new style classes,
> any suggestions?
Coercion is going away, though it may be hard to find solid information
about what's going away from where when.
See PEP 208, http://www.python.org/peps/pep-0208.html for more.
In particular, you can find some current details at:
It is no longer recommended to define a coercion operation. Mixed-mode
operations on types that don't define coercion pass the original arguments
to the operation.
New-style classes (those derived from object) never invoke the __coerce__()
method in response to a binary operator; the only time __coerce__() is
invoked is when the built-in function coerce() is called.
and you're apparently being bitten by the second of these
two points I'm quoting.
More information about the Python-list