Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #57812 > unrolled thread
| Started by | Johannes Bauer <dfnsonfsduifb@gmx.de> |
|---|---|
| First post | 2013-10-28 13:00 +0100 |
| Last post | 2013-10-28 14:31 -0400 |
| Articles | 4 — 3 participants |
Back to article view | Back to comp.lang.python
Python3 doc, operator reflection Johannes Bauer <dfnsonfsduifb@gmx.de> - 2013-10-28 13:00 +0100
Re: Python3 doc, operator reflection Chris Angelico <rosuav@gmail.com> - 2013-10-28 23:23 +1100
Re: Python3 doc, operator reflection Johannes Bauer <dfnsonfsduifb@gmx.de> - 2013-10-28 13:45 +0100
Re: Python3 doc, operator reflection random832@fastmail.us - 2013-10-28 14:31 -0400
| From | Johannes Bauer <dfnsonfsduifb@gmx.de> |
|---|---|
| Date | 2013-10-28 13:00 +0100 |
| Subject | Python3 doc, operator reflection |
| Message-ID | <bd71ueFqcsiU1@mid.dfncis.de> |
Hi group, in http://docs.python.org/3/reference/datamodel.html#customization the doc reads: > There are no swapped-argument versions of these methods (to be used when the left argument does not support the operation but the right argument does); rather, __lt__() and __gt__() are each other’s reflection, __le__() and __ge__() are each other’s reflection, and __eq__() and __ne__() are their own reflection. But shouldn't __lt__ be the reflection or __ge__ and __gt__ the reflection of __le__? Best regards, Johannes
[toc] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-10-28 23:23 +1100 |
| Message-ID | <mailman.1696.1382963021.18130.python-list@python.org> |
| In reply to | #57812 |
On Mon, Oct 28, 2013 at 11:00 PM, Johannes Bauer <dfnsonfsduifb@gmx.de> wrote: >> There are no swapped-argument versions of these methods (to be used when the left argument does not support the operation but the right argument does); rather, __lt__() and __gt__() are each other’s reflection, __le__() and __ge__() are each other’s reflection, and __eq__() and __ne__() are their own reflection. > > But shouldn't __lt__ be the reflection or __ge__ and __gt__ the > reflection of __le__? lt is the negation of ge, but it's the reflection of gt. Consider this: 1 < 2 2 > 1 If Python can't ask 1 if it's less than 2, it'll ask 2 if it's greater than 1. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Johannes Bauer <dfnsonfsduifb@gmx.de> |
|---|---|
| Date | 2013-10-28 13:45 +0100 |
| Message-ID | <bd74k7Fqup0U1@mid.dfncis.de> |
| In reply to | #57813 |
Am 28.10.2013 13:23, schrieb Chris Angelico: > On Mon, Oct 28, 2013 at 11:00 PM, Johannes Bauer <dfnsonfsduifb@gmx.de> wrote: >>> There are no swapped-argument versions of these methods (to be used when the left argument does not support the operation but the right argument does); rather, __lt__() and __gt__() are each other’s reflection, __le__() and __ge__() are each other’s reflection, and __eq__() and __ne__() are their own reflection. >> >> But shouldn't __lt__ be the reflection or __ge__ and __gt__ the >> reflection of __le__? > > lt is the negation of ge, but it's the reflection of gt. Consider this: > > 1 < 2 > 2 > 1 > > If Python can't ask 1 if it's less than 2, it'll ask 2 if it's greater than 1. Ah, I see. Thanks for clearing that up! Best regards, Joe
[toc] | [prev] | [next] | [standalone]
| From | random832@fastmail.us |
|---|---|
| Date | 2013-10-28 14:31 -0400 |
| Message-ID | <mailman.1711.1382985091.18130.python-list@python.org> |
| In reply to | #57812 |
On Mon, Oct 28, 2013, at 8:00, Johannes Bauer wrote: > Hi group, > > in http://docs.python.org/3/reference/datamodel.html#customization the > doc reads: > > > There are no swapped-argument versions of these methods (to be used when the left argument does not support the operation but the right argument does); rather, __lt__() and __gt__() are each other’s reflection, __le__() and __ge__() are each other’s reflection, and __eq__() and __ne__() are their own reflection. > > But shouldn't __lt__ be the reflection or __ge__ and __gt__ the > reflection of __le__? No... a < b is b > a - you're thinking of the relationship between a < b and not(a >= b), which is not the argument-swapping it is referring to.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web