Sorting dict keys

montyphyton at montyphyton at
Sat Jul 21 10:44:09 CEST 2007

On 21 srp, 02:31, Steven D'Aprano
<st... at> wrote:
> On Fri, 20 Jul 2007 15:27:51 -0700, montyphyton wrote:
> >>>> b = a.keys()
> >>>> b.sort()
> > [1, 2, 3]
> > Works fine, but I would really like it if I could somehow do it in one
> > line.
> Why? Is the Enter key on your keyboard broken? Is there a global shortage
> of newline characters that I haven't been told about? Does your employer
> pay you less if you write more lines?
> --
> Steven.

I'd like to do it in one line because what I am trying to do is, after
all, a single, simple enough action. 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...
Do I get payed less for more source code? Since I'm a student, I don't
get payed at all, regardless of number of lines :)

More information about the Python-list mailing list