fixed typos, added watermark info

This commit is contained in:
rasbt 2014-07-04 21:13:11 -04:00
parent 9db24a8d83
commit 94d3ea9488
2 changed files with 79 additions and 20 deletions

View File

@ -1,7 +1,7 @@
{
"metadata": {
"name": "",
"signature": "sha256:27a1e02eab6a2a036c525e3b099008ab58937df3266f55f5072b9a68b1693306"
"signature": "sha256:7417613f49b14e98fba46fa1e285f4e3d46728b4798e853cfb103caef077b452"
},
"nbformat": 3,
"nbformat_minor": 0,
@ -25,10 +25,18 @@
"cell_type": "code",
"collapsed": false,
"input": [
"import time\n",
"import platform\n",
"print('Last updated: %s' %time.strftime('%d/%m/%Y'))\n",
"print('Created using Python', platform.python_version())"
"%load_ext watermark"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 1
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%watermark -a 'Sebastian Raschka' -v -d -p numpy,scipy,matplotlib,scikit-learn"
],
"language": "python",
"metadata": {},
@ -37,12 +45,26 @@
"output_type": "stream",
"stream": "stdout",
"text": [
"Last updated: 26/06/2014\n",
"Created using Python 3.4.1\n"
"Sebastian Raschka 04/07/2014 \n",
"\n",
"CPython 3.4.1\n",
"IPython 2.1.0\n",
"\n",
"numpy 1.8.1\n",
"scipy 0.14.0\n",
"matplotlib 1.3.1\n",
"scikit-learn 0.15.0b1\n"
]
}
],
"prompt_number": 1
"prompt_number": 5
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<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>"
]
},
{
"cell_type": "markdown",

View File

@ -1,7 +1,7 @@
{
"metadata": {
"name": "",
"signature": "sha256:134ba1fb10441f1756c0ab8a2ecef528f9c1cfd7543d8df415e2ae855f6891f9"
"signature": "sha256:b33e0c5563d80d68580ea6ce62ae2703856ccde40aec8ff9fb1364ac70d70521"
},
"nbformat": 3,
"nbformat_minor": 0,
@ -13,12 +13,49 @@
"metadata": {},
"source": [
"[Sebastian Raschka](http://www.sebastianraschka.com) \n",
"last updated: 04/28/2014\n",
"\n",
"- [Link to the containing GitHub Repository](https://github.com/rasbt/python_reference)\n",
"- [Link to this IPython Notebook on GitHub](https://github.com/rasbt/python_reference/blob/master/tutorials/scope_resolution_legb_rule.ipynb)\n",
"\n",
"Note: The code in this IPython notebook was executed in Python 3.4.0"
"- [Link to this IPython Notebook on GitHub](https://github.com/rasbt/python_reference/blob/master/tutorials/scope_resolution_legb_rule.ipynb)\n"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%load_ext watermark"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 1
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%watermark -a 'Sebastian Raschka' -v -d"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Sebastian Raschka 04/07/2014 \n",
"\n",
"CPython 3.3.5\n",
"IPython 2.1.0\n"
]
}
],
"prompt_number": 3
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<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>"
]
},
{
@ -26,9 +63,9 @@
"metadata": {},
"source": [
"<hr>\n",
"I am really looking forward to your comments and suggestions to improve and extend this tutorial! Just send me a quick note \n",
"via Twitter: [&#64;rasbt](https://twitter.com/rasbt) \n",
"or Email: [bluewoodtree@gmail.com](mailto:bluewoodtree@gmail.com)\n",
"I would be happy to hear your comments and suggestions. \n",
"Please feel free to drop me a note via\n",
"[twitter](https://twitter.com/rasbt), [email](mailto:bluewoodtree@gmail.com), or [google+](https://plus.google.com/+SebastianRaschka).\n",
"<hr>"
]
},
@ -207,7 +244,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"So, how does Python now which namespace it has to search if we want to print the value of the variable `i`? This is where Python's LEGB-rule comes into play, which we will discuss in the next section."
"So, how does Python know which namespace it has to search if we want to print the value of the variable `i`? This is where Python's LEGB-rule comes into play, which we will discuss in the next section."
]
},
{
@ -274,7 +311,7 @@
"- *Global* refers to the uppermost level of the executing script itself, and \n",
"- *Built-in* are special names that Python reserves for itself. \n",
"\n",
"So, if a particular name:object mapping cannot be found in the local namespaces, the namespaces of the enclosed scope are being searched next. If the search in the enclosed scope is unsuccessful, too, Python moves on to the global namespace, and eventually, it will search the global namespaces (side note: if a name cannot found in any of the namespaces, a *NameError* will is raised).\n",
"So, if a particular name:object mapping cannot be found in the local namespaces, the namespaces of the enclosed scope are being searched next. If the search in the enclosed scope is unsuccessful, too, Python moves on to the global namespace, and eventually, it will search the built-in namespace (side note: if a name cannot found in any of the namespaces, a *NameError* will is raised).\n",
"\n",
"**Note**: \n",
"Namespaces can also be further nested, for example if we import modules, or if we are defining new classes. In those cases we have to use prefixes to access those nested namespaces. Let me illustrate this concept in the following code block:"
@ -635,7 +672,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Similar to the concept of the `global` keyword, which we have seen in the section above, we can use the keyword `nonlocal` inside the inner function to explicitely access a variable from the outer (enclosed) scope in order to modify its value. \n",
"Similar to the concept of the `global` keyword, which we have seen in the section above, we can use the keyword `nonlocal` inside the inner function to explicitly access a variable from the outer (enclosed) scope in order to modify its value. \n",
"Note that the `nonlocal` keyword was added in Python 3.x and is not implemented in Python 2.x (yet)."
]
},
@ -1020,7 +1057,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"**This also applies if we explicitely defined the `for-loop` variable in the global namespace before!** In this case it will rebind the existing variable:"
"**This also applies if we explicitly defined the `for-loop` variable in the global namespace before!** In this case it will rebind the existing variable:"
]
},
{