On Mon, Jul 15, 2013 at 03:34:08PM +1200, Ben Hoyt wrote:
> Thanks, Nick -- that's helpful info. Writing such a PEP is a nice idea, but
> I think it'd be beyond me (I'm not familiar enough with CPython internals,
> protocols, etc).
> 
> Can you explain what you mean by "symmetric protocol rather than the
> current only-controlled-by-the-container behaviour"?

Most operators can be controlled by either the left-hand or right-hand 
operand. For example, x + y can end up calling either x.__add__(y) or 
y.__radd_(x). The `in` operator is an exception, it only ever calls the 
container:

x in y => y.__contains__(x)

but never x.__contained_by__(y)



-- 
Steven
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to