[Tutor] dict(a, b) does not preserve sort order
Joel Rodrigues
joelrodrigues at ifrance.com
Thu Jan 15 13:38:59 EST 2004
Am I wrong to be a just a wee bit annoyed about this ? :
>>> a
('1', '2', '3')
>>> b
('x', 'y', 'z')
>>> zip(a,b)
[('1', 'x'), ('2', 'y'), ('3', 'z')]
>>> dict(zip(a,b))
{'1': 'x', '3': 'z', '2': 'y'}
What I expect is :
{'1': 'x', '2': 'y', '3': 'z'}
- Joel
_____________________________________________________________________
Envie de discuter en "live" avec vos amis ? Télécharger MSN Messenger
http://www.ifrance.com/_reloc/m la 1ère messagerie instantanée de France
More information about the Tutor
mailing list