2016-11-30 | Paul Boddie | raw annotate files changeset graph | Added dict support, changing the literal instantiators to use functions appropriate for sequences or mappings that set the __data__ attribute on each new instance. Added a __hash__ method for integers. |
1 def f(d): 2 return d.keys() 3 4 #def g(d): 5 # for key, value in d.items(): 6 # return value 7 8 d = {10 : "a", 20 : "b"} 9 l = f(d) 10 print 10 in l # True 11 print 20 in l # True 12 print 30 in l # False 13 14 l = d.values() 15 print "a" in l # True 16 print "b" in l # True 17 print "c" in l # False 18 19 20 #v = g(d) # either "a" or "b" 21 #print v == "a" or v == "b" # True