mirror of
https://github.com/rasbt/python_reference.git
synced 2024-11-23 20:11:13 +00:00
small wording change in closure-section
This commit is contained in:
parent
936c755d98
commit
a52226cd70
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"name": "",
|
"name": "",
|
||||||
"signature": "sha256:d87105a74c8f25016f90bdec495a890a988277a3f51e0589febbbac87720b033"
|
"signature": "sha256:5dd675ee714d0dbd00f7be378f1379f4dceaa728c56476124c1bf493d70c569e"
|
||||||
},
|
},
|
||||||
"nbformat": 3,
|
"nbformat": 3,
|
||||||
"nbformat_minor": 0,
|
"nbformat_minor": 0,
|
||||||
|
@ -13,18 +13,60 @@
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"[Sebastian Raschka](http://sebastianraschka.com) \n",
|
"[Sebastian Raschka](http://sebastianraschka.com) \n",
|
||||||
"last updated: 05/24/2014 ([Changelog](#changelog))\n",
|
|
||||||
"\n",
|
"\n",
|
||||||
"- [Link to this IPython Notebook on GitHub](https://github.com/rasbt/python_reference/blob/master/tutorials/not_so_obvious_python_stuff.ipynb) \n",
|
"- [Link to this IPython Notebook on GitHub](https://github.com/rasbt/python_reference/blob/master/tutorials/not_so_obvious_python_stuff.ipynb) \n",
|
||||||
"- [Link to the GitHub repository](https://github.com/rasbt/python_reference) \n",
|
"- [Link to the GitHub repository](https://github.com/rasbt/python_reference) \n",
|
||||||
"\n"
|
"\n"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"collapsed": false,
|
||||||
|
"input": [
|
||||||
|
"%load_ext watermark"
|
||||||
|
],
|
||||||
|
"language": "python",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"prompt_number": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"collapsed": false,
|
||||||
|
"input": [
|
||||||
|
"%watermark -d -u -v"
|
||||||
|
],
|
||||||
|
"language": "python",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"output_type": "stream",
|
||||||
|
"stream": "stdout",
|
||||||
|
"text": [
|
||||||
|
"Last updated: 16/07/2014 \n",
|
||||||
|
"\n",
|
||||||
|
"CPython 3.4.1\n",
|
||||||
|
"IPython 2.0.0\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"prompt_number": 2
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"#### All code was executed in Python 3.4 (unless stated otherwise)"
|
"<font size=\"1.5em\">[More information](http://nbviewer.ipython.org/github/rasbt/python_reference/blob/master/ipython_magic/watermark.ipynb) about the `watermark` magic command extension.</font>\n",
|
||||||
|
"\n",
|
||||||
|
"([Changelog](#changelog))"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"<br>\n",
|
||||||
|
"<br>"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1013,7 +1055,7 @@
|
||||||
"\n",
|
"\n",
|
||||||
"(Original source: [http://openhome.cc/eGossip/Blog/UnderstandingLambdaClosure3.html](http://openhome.cc/eGossip/Blog/UnderstandingLambdaClosure3.html))\n",
|
"(Original source: [http://openhome.cc/eGossip/Blog/UnderstandingLambdaClosure3.html](http://openhome.cc/eGossip/Blog/UnderstandingLambdaClosure3.html))\n",
|
||||||
"\n",
|
"\n",
|
||||||
"In the first example below, we call a `lambda` function in a list comprehension, and the value `i` will be dereferenced every time we call `lambda` within the scope of the list comprehension. Since the list is already constructed when we `for-loop` through the list, it will be set to the last value 4."
|
"In the first example below, we call a `lambda` function in a list comprehension, and the value `i` will be dereferenced every time we call `lambda` within the scope of the list comprehension. Since the list comprehension has already been constructed and evaluated when we for-loop through the list, the closure-variable will be set to the last value 4."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1045,7 +1087,7 @@
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"This, however, does not apply to generators:"
|
"However, by using a generator expression, we can make use of its stepwise evaluation (note that the returned variable still stems from the same closure, but the value changes as we iterate over the generator)."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -4281,6 +4323,9 @@
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
|
"#### 07/16/2014\n",
|
||||||
|
"- slight change of wording in the [lambda-closure section](#lambda_closure)\n",
|
||||||
|
"\n",
|
||||||
"#### 05/24/2014\n",
|
"#### 05/24/2014\n",
|
||||||
"- new section: unorderable types in Python 2\n",
|
"- new section: unorderable types in Python 2\n",
|
||||||
"- table of contents for the Python 2 vs. Python 3 topic\n",
|
"- table of contents for the Python 2 vs. Python 3 topic\n",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user