Hello everyone, here is my pb: Since i'm using python 3.9, 'm aware that dictionnary keys are displayed in the order of their input. Still, i'd like the resulting dict to be "pretty" displayed. Below is the original dict with the correct key order:
{'intitule_semestre': 'adapt', 'semaine_debut': 38, 'annee_debut': 2020, 'semaine_fin': 44, 'annee_fin': 2020, 'nb_semaines': 7, 'plage_semestre': 2020-09-14T00:00:00 - 2020-10-30T00:00:00}
And here's the pprint result (using pprint or beeprint):
{ 'annee_debut': 2020, 'annee_fin': 2020, 'intitule_semestre': 'adapt', 'nb_semaines': 7, 'plage_semestre': 2020-09-14T00:00:00 - 2020-10-30T00:00:00 'semaine_debut': 38, 'semaine_fin': 44, } => alphabetical order!!! Why is that? How can I pretty print my dict with keeping the original order? Thank for your help Zemaf
Finally figured out how to work this out : by setting PrettyPrinter parameter "sort_dicts" to False keys are ordered according to input order, not alphabetical order (sort_dicts=True by default)!