Skip to content

Commit 89de42b

Browse files
committed
exaples with dictionary
1 parent 42e40c0 commit 89de42b

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

example_2.py

+42
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,45 @@ def magic():
5858

5959
x_8 = OrderedDict([(1, 2), (3, 4), (5, 6)])
6060
print(y_8.get(999, 42))
61+
62+
class Magic:
63+
def __hash__(self):
64+
return 42
65+
66+
def __eq__(self, other):
67+
return True
68+
69+
# def __str__(self):
70+
# return "yolo"
71+
#
72+
# __repr__ = __str__
73+
74+
75+
def magic_fn():
76+
...
77+
78+
79+
x_10 = {
80+
1: 0,
81+
False: 1,
82+
True: 2,
83+
0: 3,
84+
"ala": 4,
85+
"": 5,
86+
"": 6,
87+
(1,): 7,
88+
(1, 2): 8,
89+
None: 9,
90+
Magic: 10,
91+
Magic(): 11,
92+
magic_fn: 12,
93+
Magic(): 13
94+
}
95+
96+
print(x_10)
97+
#
98+
# print(x[0.0000000000000])
99+
# print(x[0])
100+
# print(x[False])
101+
102+
print(x_10[Magic()])

0 commit comments

Comments
 (0)