Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #70673 > unrolled thread
| Started by | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| First post | 2014-04-28 06:28 -0400 |
| Last post | 2014-04-29 12:08 +1200 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Inconsistent viewkeys behaviour Terry Reedy <tjreedy@udel.edu> - 2014-04-28 06:28 -0400
Re: Inconsistent viewkeys behaviour Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-04-29 12:08 +1200
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2014-04-28 06:28 -0400 |
| Subject | Re: Inconsistent viewkeys behaviour |
| Message-ID | <mailman.9546.1398680984.18130.python-list@python.org> |
On 4/28/2014 2:22 AM, Joshua Landau wrote: > Is there any reference for this strange behaviour on Python 2: > > >>> set() < dict().viewkeys() > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > TypeError: can only compare to a set > >>> dict().viewkeys() > set() > False The left operand determines the result. The manual specifies that < and > do not have to be consistent. But I suspect that when 3.x dict.keys() was backported to 2.7.0, no one thought to update set, whereas the backported key view code already had the comparison. -- Terry Jan Reedy
[toc] | [next] | [standalone]
| From | Gregory Ewing <greg.ewing@canterbury.ac.nz> |
|---|---|
| Date | 2014-04-29 12:08 +1200 |
| Message-ID | <bs88shF6fvqU1@mid.individual.net> |
| In reply to | #70673 |
Terry Reedy wrote: > The left operand determines the result. The manual specifies that < and > > do not have to be consistent. But I suspect that when 3.x dict.keys() > was backported to 2.7.0, no one thought to update set, whereas the > backported key view code already had the comparison. The question is why set() is raising an exception instead of returning NotImplemented to give the other operand a chance. -- Greg
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web