Message317053
With Tim's addition
>>> from fractions import Fraction as F
>>> from decimal import Decimal as D
>>> s = {0, 1, 0.0, 1.0, F(0,1), F(1, 1), D(0), D(1), False, True}
>>> s
{0, 1}
I think we should consider moving the main discussion of the general comparison and hashing principle and example to the set entry. (Sets ars simpler and are when people new to Python already know about.) Point out that for displays, the first of equals is kept and not replaced (this is also true of dicts). Then, in the dict entry, say that dict keys are treated like set items, give an equivalent dict example, and link to the discussion of set items.
>>> x = None
>>> d = {0:x, 1:x, 0.0:x, 1.0:x, F(0,1):x, F(1, 1):x, D(0):x, D(1):x, False:x, True:x}
>>> d
{0: None, 1: None}
>>> |
|
Date |
User |
Action |
Args |
2018-05-18 19:44:10 | terry.reedy | set | recipients:
+ terry.reedy, tim.peters, mark.dickinson, docs@python, Janusz Harkot |
2018-05-18 19:44:10 | terry.reedy | set | messageid: <1526672650.81.0.682650639539.issue33572@psf.upfronthosting.co.za> |
2018-05-18 19:44:10 | terry.reedy | link | issue33572 messages |
2018-05-18 19:44:10 | terry.reedy | create | |
|