Re: Sorting dict keys
- From: Bjoern Schliessmann <usenet-mail-0306.20.chr0n0ss@xxxxxxxxxxxxxxx>
- Date: Sat, 21 Jul 2007 12:02:59 +0200
montyphyton@xxxxxxxxx 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.
Regards,
Björn
--
BOFH excuse #450:
Terrorists crashed an airplane into the server room, have to
remove /bin/laden. (rm -rf /bin/laden)
.
- Follow-Ups:
- Re: Sorting dict keys
- From: zacherates
- Re: Sorting dict keys
- References:
- Sorting dict keys
- From: montyphyton
- Re: Sorting dict keys
- From: Steven D'Aprano
- Re: Sorting dict keys
- From: montyphyton
- Sorting dict keys
- Prev by Date: Re: Permutations with generators
- Next by Date: h grup
- Previous by thread: Re: Sorting dict keys
- Next by thread: Re: Sorting dict keys
- Index(es):
Relevant Pages
|
|