4 ms·
Python only has single line lambdas. Rumor control. While it is true that the lambda construct in Python is only one line, Python allows you to define functio
by btilly 16y ago
Python only has single line lambdas.
Rumor control. While it is true that the lambda construct in Python is only one line, Python allows you to define functions in any scope, and pass those functions around. They are full closures. So anything you wanted to do with multi-line lambdas you can.
- epochwolf 16y agoYes, but I've found it to be rather cumbersome compared to ruby and under utilized. The standard library doesn't seem to make much of an attempt to pass around functions whereas in ruby you are often using code blocks to replace loops. Ruby's ability to hijack the scope of a given block via class_eval is amazingly useful in creating DSLs. Creating DSLs in ruby is trivial. The router for Rails 3 is a perfect example of this. Python makes this far more difficult.