I have the following testcase_dict.py
script:
print([{x: 'hello', 'x': 'y'} for x in [1, 2]])
I run this script, and every 15 times, 2-4 times it gives me distincted results:
$ for i in $(seq 15); do python testcase_dict.py; done
[{1: 'hello', 'x': 'y'}, {2: 'hello', 'x': 'y'}]
[{1: 'hello', 'x': 'y'}, {2: 'hello', 'x': 'y'}]
[{1: 'hello', 'x': 'y'}, {'x': 'y', 2: 'hello'}]
[{1: 'hello', 'x': 'y'}, {2: 'hello', 'x': 'y'}]
[{1: 'hello', 'x': 'y'}, {2: 'hello', 'x': 'y'}]
[{1: 'hello', 'x': 'y'}, {2: 'hello', 'x': 'y'}]
[{'x': 'y', 1: 'hello'}, {'x': 'y', 2: 'hello'}]
[{1: 'hello', 'x': 'y'}, {2: 'hello', 'x': 'y'}]
[{1: 'hello', 'x': 'y'}, {'x': 'y', 2: 'hello'}]
[{1: 'hello', 'x': 'y'}, {2: 'hello', 'x': 'y'}]
[{1: 'hello', 'x': 'y'}, {2: 'hello', 'x': 'y'}]
[{1: 'hello', 'x': 'y'}, {'x': 'y', 2: 'hello'}]
[{'x': 'y', 1: 'hello'}, {'x': 'y', 2: 'hello'}]
[{1: 'hello', 'x': 'y'}, {2: 'hello', 'x': 'y'}]
[{1: 'hello', 'x': 'y'}, {2: 'hello', 'x': 'y'}]
Why this happens and how can I prevent it. This may be a reason of some raise conditions which are strongly unwelcome.
My Python version is 3.5.2.
My question DOES NOT regard specific order, just deterministic one.