Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

Jonathan Gardner jgardner at jonathangardner.net
Thu Feb 18 20:11:19 EST 2010


On Feb 18, 3:04 pm, "sjdevn... at yahoo.com" <sjdevn... at yahoo.com> wrote:
>
> You could do it without intermediate names or lambdas in Python as:
> def print_numbers():
>     for i in [ cube for (square, cube) in
>                          [(n*n, n*n*n) for n in [1,2,3,4,5,6]]
>                if square!=25 and cube!=64 ]:
>         print i
>
> But frankly, although there's no reason that you _have_ to name the
> content at each step, I find it a lot more readable if you do:
>
> def print_numbers():
>     tuples = [(n*n, n*n*n) for n in (1,2,3,4,5,6)]
>     filtered = [ cube for (square, cube) in tuples if square!=25 and
> cube!=64 ]
>     for f in filtered:
>         print f

Step away from the keyboard! This is a programmer's arrest!

There are laws around here, laws that we can't allow to be broken.
You've just broken 12 of them. You think the laws don't apply to you,
huh, punk? HUH?

I'm sentencing you to three months HARD LABOR in Ruby for that code
you just wrote. And if you think it's too harsh, then I'll sentence
you to NINE MONTHS PHP and see how you feel about that!

;-)



More information about the Python-list mailing list