[Python-Dev] Keep default comparisons - or add a second set?
Adam Olsen
rhamph at gmail.com
Wed Dec 28 11:01:39 CET 2005
On 12/27/05, Scott David Daniels <Scott.Daniels at acm.org> wrote:
> Tell me:
> >>> a = [0] * 3
> >>> b = [0] * 3
> >>> a[0] = b
> >>> b[0] = a
>
> What order should a and b have?
More gems:
>>> Decimal(3) < 4.0
False
>>> Decimal(3) == 3.0
False
>>> Decimal(3) > 4.0
True
And the pièce de résistance:
>>> l = [2.0, Decimal(3), 3.5, Decimal(4), 5, 3]
>>> for i in range(5): random.shuffle(l); print sorted(l)
[2.0, Decimal("3"), 3, 3.5, Decimal("4"), 5]
[2.0, 3.5, Decimal("3"), 3, Decimal("4"), 5]
[2.0, Decimal("3"), 3, 3.5, Decimal("4"), 5]
[2.0, 3.5, Decimal("3"), 3, Decimal("4"), 5]
[2.0, 3, 3.5, Decimal("3"), Decimal("4"), 5]
(The positions of 3 and Decimal("3") should be swapping, but the
position of 3.5 should not.)
--
Adam Olsen, aka Rhamphoryncus
More information about the Python-Dev
mailing list