mirror of
https://github.com/rasbt/python_reference.git
synced 2025-01-18 15:27:09 +00:00
typo upd.
This commit is contained in:
parent
7290f5c862
commit
2587ebf9db
|
@ -59,7 +59,7 @@
|
|||
"source": [
|
||||
"## Sections\n",
|
||||
"- [Introduction to namespaces and scopes](#introduction) \n",
|
||||
"- [1. LG - Local vs. Global](#section_1) \n",
|
||||
"- [1. LG - Local and Global scopes](#section_1) \n",
|
||||
"- [2. LEG - Local, Enclosed, and Global scope](#section_2) \n",
|
||||
"- [3. LEGB - Local, Enclosed, Global, Built-in](#section_3) \n",
|
||||
"- [Self-assessment exercise](#assessment)\n",
|
||||
|
@ -272,6 +272,13 @@
|
|||
"<br>"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 1. LG - Local and Global scopes"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
|
@ -483,6 +490,26 @@
|
|||
"<br>"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Tip:\n",
|
||||
"If we want to print out the dictionary mapping of the global and local variables, we can use the\n",
|
||||
"the functions `global()` and `local()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": [
|
||||
"print(global()) # prints global namespace\n",
|
||||
"print(local()) # prints local namespace"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
|
@ -979,7 +1006,7 @@
|
|||
"b = 1\n",
|
||||
"for b in range(5):\n",
|
||||
" if b == 4:\n",
|
||||
" print(a, '-> b in for-loop')\n",
|
||||
" print(b, '-> b in for-loop')\n",
|
||||
"print(b, '-> b in global')"
|
||||
],
|
||||
"language": "python",
|
||||
|
@ -994,7 +1021,7 @@
|
|||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 17
|
||||
"prompt_number": 7
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
|
@ -1023,7 +1050,7 @@
|
|||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 14
|
||||
"prompt_number": 1
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
|
|
Loading…
Reference in New Issue
Block a user