Where is ^ (symmetric_difference) documented in help()?
Steve D'Aprano
steve+python at pearwood.info
Sat Dec 23 00:30:32 EST 2017
On Sat, 23 Dec 2017 03:50 pm, Peng Yu wrote:
> Where is it documented that __xor__ and ^ is the same as
> symmetric_difference? Thanks.
You read
https://docs.python.org/2/library/stdtypes.html#set
to learn that ^ is the same as symmetric difference, and then read:
https://docs.python.org/2/reference/datamodel.html#emulating-numeric-types
to learn that you must override __xor__ to override the ^ operator.
It isn't really clear from the documentation that the set operator ^ is
implemented by __xor__ (and also __rxor__). Perhaps you can suggest a
documentation patch?
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
More information about the Python-list
mailing list