Sorting dict keys

Bjoern Schliessmann usenet-mail-0306.20.chr0n0ss at
Sat Jul 21 12:02:59 CEST 2007

 montyphyton at wrote:

> I'd like to do it in one line because what I am trying to do is,
> after all, a single, simple enough action. 

No, it's two actions: 

1. You extract a list of keys from the dict
2. you sort it

> I find the suggested b = sorted(a.keys()) much more readable than
> breaking it up in two lines. In the long run, I guess it's a
> matter of personal taste... 

Yes. You'll see, at least if you do a third thing with the list it
will start to become less well-readable.



BOFH excuse #450:

Terrorists crashed an airplane into the server room, have to
remove /bin/laden. (rm -rf /bin/laden)

More information about the Python-list mailing list