lambdak: multi-line lambda implementation in native Python

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sat Jan 17 11:30:55 CET 2015


Gregory Ewing wrote:

> We're really quite spoiled in Python-land. It's easy
> to forget just how spoiled we are until you go back
> and try to do something in one of the more primitive
> languages...

Every time I think I would like to learn a new language, I quite quickly run
into some obvious feature that Python has but the newer language lacks, and
I think "bugger this for a game of soldiers" and abandon it. E.g. Ruby and
the lack of keyword arguments. Oh, I see Ruby 2.0 added them to the
language! Perhaps it's time for me to give Ruby a go again?

Ah, wait, I forgot Ruby's brilliant "feature" that whitespace *between*
expressions is significant:

[steve at ando ~]$ cat ~/coding/ruby/ws-example.rb
#!/usr/bin/ruby

def a(x=4)
    x+2
end

b = 1
print "a + b => ", (a + b), "\n"
print "a+b   => ", (a+b), "\n"
print "a+ b  => ", (a+ b), "\n"
print "a +b  => ", (a +b), "\n"

[steve at ando ~]$ ruby ~/coding/ruby/ws-example.rb
a + b => 7
a+b   => 7
a+ b  => 7
a +b  => 3


A shiny new penny for any non-Ruby coder who can explain that!



-- 
Steven




More information about the Python-list mailing list