[Tutor] enumerate over Dictionaries

Animesh Bhadra animeshb.social at gmail.com
Fri Jul 5 12:32:59 EDT 2019


Thanks Alan and Mats for the explanation.

On 05/07/19 19:57, Mats Wichmann wrote:
> On 7/4/19 3:53 PM, Alan Gauld via Tutor wrote:
>
>>> Does this means that the Dict is ordered? or it is implementation dependent?
>> Neither, it means the items in a list always have indexes
>> starting at zero.
>>
>> By pure coincidence dictionaries in recent Python versions (since 3.6
>> or 3.7???) retain their insertion order. But that was not always the
>> case, but the result would have been the same so far as the 0,1,2 bit goes.
>>
> To be a little more precise, in 3.6 CPython insertion order was
> preserved as an artefact of the new implementation of dicts, but not
> promised to be that way. Since 3.7 it is guaranteed (it is actually in
> the language specification, so other Pythons have to do this too now).
>
> It's still not the same as a collections.OrderedDict, which has some
> useful additional features in case you care a lot about ordering.
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor


More information about the Tutor mailing list