This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients Arfrever, docs@python, loewis, max, r.david.murray, terry.reedy
Date 2012-09-22.22:44:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1348353881.43.0.242902847995.issue15997@psf.upfronthosting.co.za>
In-reply-to
Content
I was wrong about TypeError; forget that. The seeming equivalent to 'return NotImplement' is not defining the method. My confusion stemed from the fact that NotImplemented returned from special methods gets intercepted and converted to TypeError exceptions by the operator functions that call them -- unless there is an alternate path *and* the alternate does not also return NotImplemented.

Changing "will try reflected operation" to "will return the result of the reflected operation called on the swapped arguments" is wrong as the latter is not completely correct. If the fallback also returns NotImplemented, it is ignored and TypeError is raised the same as if the fallback did not exist. But as Martin said, the details belong in operator documentation.

I would like to more closely parallel the None entry, which has

"It is used to signify the absence of a value in many situations, e.g.  it is returned from functions that don’t explicitly return anything."

by replacing

"Numeric methods and rich comparison methods may return this value if they do not implement the operation for the operands provided. (The interpreter will then try the reflected operation, or some other fallback, depending on the operator.)"

with

"It is used to signify that a method does not implement the operation requested for the operands provided. For example, the special methods for arithmetic and and rich comparison may return NotImplemented, and when they do, the interpreter will try the reversed or reflected operation."
History
Date User Action Args
2012-09-22 22:44:41terry.reedysetrecipients: + terry.reedy, loewis, Arfrever, r.david.murray, docs@python, max
2012-09-22 22:44:41terry.reedysetmessageid: <1348353881.43.0.242902847995.issue15997@psf.upfronthosting.co.za>
2012-09-22 22:44:40terry.reedylinkissue15997 messages
2012-09-22 22:44:40terry.reedycreate