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

Paul Rubin no.email at nospam.invalid
Fri Feb 19 00:26:52 EST 2010


Steve Howell <showell30 at yahoo.com> writes:
>> http://haskell.org/ghc/docs/6.10.4/html/users_guide/syntax-extns.html...
>> might be of interest.  Maybe Ruby and/or Python could grow something similar.
> Can you elaborate?

List comprehensions are a Python feature you're probably familiar with,
and I think Ruby has something like them too.  They originally came from
Haskell.  GHC (the main Haskell implementation) now supports an extended
list comprehension syntax with SQL-like features.  I haven't used it
much yet, but here's an example from a poker ranking program
(http://www.rubyquiz.com/quiz24.html) that I did as a Haskell exercise:

  let (winners:others) = 
        [zip c ls | ls <- lines cs
                , let {h = mkHand ls; c=classify h}
                , then group by c
                , then sortWith by Down c]

It's reasonably evocative and doing the same thing with the older
syntax would have been a big mess.  "Down" basically means sort
in reverse order.



More information about the Python-list mailing list