What are the differences between Ruby's blocks and Python's lambdas?

Greg Ewing (using news.cis.dfn.de) me at privacy.net
Wed Mar 26 22:43:08 EST 2003


sdieselil wrote:
> What are the differences between Ruby's blocks and Python's lambdas?

The main one is that a Python lambda can only contain
an expression, whereas a Ruby block can contain arbitrary
statements.

If that restriction were lifted one day (discussions
come up periodically about doing that somehow) there
would remain another difference -- in Python, names
cannot be rebound in a lexically enclosing local
scope.

-- 
Greg Ewing, Computer Science Dept,
University of Canterbury,	
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg





More information about the Python-list mailing list