Here is a code snippet.
x = {}
x[1] = len(x)
print x
{1: 0}
Is this well defined? That is, could x == {1: 1}
instead?
Because I remember that an equivalent program in C++ '98 (if we use std::map
) has undefined behaviour. The output of the program was different when compiled with VS compiler and G++.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…