Dictionary Bug ? Python 1.5 & 2.2
A.A
andtherewaswater at yahoo.com
Sun Jan 6 04:06:39 EST 2002
Hello,
I'm not sure if I should call this a bug, but it certainly is very
strange behaviour...
When I input the following at the interpreter:
On Python 1.5:
>>> # A dictionary that has the alphabets a to h as keys, and empty lists
>>> # as values
>>> a = {'a':[], 'b':[], 'c':[], 'd':[], 'e':[], 'f':[], 'g':[], 'h':[]}
>>> print a
>>> # The result is DISPLAYED in jumpled order
{'h': [], 'f': [], 'g': [], 'd': [], 'e': [], 'b': [], 'c': [], 'a':
[]}
On Python 2.2:
Here the result is the same as in Python 1.5, but its reversed !
{'a': [], 'c': [], 'b': [], 'e': [], 'd': [], 'g': [], 'h': [], 'h': []}
I came across the above when I tried this code:
for key in board.keys():
print key + " \t", board[key]
I've tried it in 'Python 1.5' on Sourceforge's servers, and the result
was the same.
Best Regards,
A.A
More information about the Python-list
mailing list