Order guaranteed with list comprehension?

Harald Massa cpl.19.ghum at spamgourmet.com
Fri May 16 05:01:39 EDT 2003


>>> maedels=['Sandra', 'Miriam', 'Katja', 'Melanie']
>>> my=[a for a in maedels if a[0]=="M"]
>>> my
['Miriam', 'Melanie']

I select part of a list ... the names starting with "M"

the comprehended list is in the same order as the basic list.

Is this guaranteed by specification or just a lucky point in the current 
Python implementation?


Thank you


Harald




More information about the Python-list mailing list