Sfoglia il codice sorgente

Tried to simplify lambda explanation

Sort key, function objects and lambda are all explained in one example. Perhaps something simpler should be used? 
Maybe something like this:  http://www.secnetix.de/olli/Python/lambda_functions.hawk. Including an example with function, and an example  with lambda.
Thanks.
dbojan 9 anni fa
parent
commit
2c2dd63799
1 ha cambiato i file con 2 aggiunte e 2 eliminazioni
  1. 2 2
      more.md

+ 2 - 2
more.md

@@ -71,7 +71,7 @@ Notice that the single statement is used in-place and not as a separate block.
 
 ## Lambda Forms
 
-A `lambda` statement is used to create new function objects. Essentially, the `lambda` takes a parameter followed by a single expression only which becomes the body of the function and the value of this expression is returned by the new function.
+A `lambda` statement is used to create new function objects. Essentially, the `lambda` takes a parameter followed by a single expression. Lambda becomes the body of the function. The value of this expression is returned by the new function.
 
 Example (save as `more_lambda.py`):
 
@@ -83,7 +83,7 @@ Output:
 
 **How It Works**
 
-Notice that the `sort` method of a `list` can take a `key` parameter which determines how the list is sorted (usually we know only about ascending or descending order). In our case, we want to do a custom sort, and for that we need to write a function but instead of writing a separate `def` block for a function that will get used in only this one place, we use a lambda expression to create a new function.
+Notice that the `sort` method of a `list` can take a `key` parameter which determines how the list is sorted (usually we know only about ascending or descending order). In our case, we want to do a custom sort, and for that we need to write a function. Instead of writing a separate `def` block for a function that will get used in only this one place, we use a lambda expression to create a new function.
 
 ## List Comprehension