News for hackers. Stuff that matters.
Re:Curing Python's Neglect by grandalf on Saturday May 30, 2009 @02:22PM (#633957)
in Python, it works like:

  foo(a, b, lambda x: x+2)
or

  foo2(a, b, foo):
      foo() # this is like js

The lambda is closed by the next ) or ,
Re:Curing Python's Neglect by natrius on Saturday May 30, 2009 @08:05PM (#634220)
Right, but you can't have multi-line anonymous functions, which are pleasant to use in Ruby and JavaScript.
Re:Curing Python's Neglect by grandalf on Saturday May 30, 2009 @11:21PM (#634383)
True, but you can just write a non-anyonymous function in the current scope, which can be passed as boo or called as boo():

  def test():
    def boo(x):
      x += 2
      x += 3
      return x
    something_else(boo, 33, "hi")

  test()
This is equivalent to how procs are often used in Ruby...