Skip to content

Commit 8e6ddff

Browse files
committed
Update 01.00-01.04
1 parent 795099e commit 8e6ddff

8 files changed

+145
-153
lines changed

notebooks_v2/01.00-IPython-Beyond-Normal-Python.ipynb

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"metadata": {},
3535
"source": [
3636
"There are many options for development environments for Python, and I'm often asked which one I use in my own work.\n",
37-
"My answer sometimes surprises people: my preferred environment is [IPython](http://ipython.org/) plus a text editor (in my case, Emacs or Atom depending on my mood).\n",
37+
"My answer sometimes surprises people: my preferred environment is [IPython](http://ipython.org/) plus a text editor (in my case, Emacs or VSCode depending on my mood).\n",
3838
"IPython (short for *Interactive Python*) was started in 2001 by Fernando Perez as an enhanced Python interpreter, and has since grown into a project aiming to provide, in Perez's words, \"Tools for the entire life cycle of research computing.\"\n",
3939
"If Python is the engine of our data science task, you might think of IPython as the interactive control panel.\n",
4040
"\n",
@@ -73,11 +73,10 @@
7373
"\n",
7474
"Once you do this, you should see a prompt like the following:\n",
7575
"```\n",
76-
"IPython 4.0.1 -- An enhanced Interactive Python.\n",
77-
"? -> Introduction and overview of IPython's features.\n",
78-
"%quickref -> Quick reference.\n",
79-
"help -> Python's own help system.\n",
80-
"object? -> Details about 'object', use 'object??' for extra details.\n",
76+
"Python 3.9.2 (v3.9.2:1a79785e3e, Feb 19 2021, 09:06:10) \n",
77+
"Type 'copyright', 'credits' or 'license' for more information\n",
78+
"IPython 7.21.0 -- An enhanced Interactive Python. Type '?' for help.\n",
79+
"\n",
8180
"In [1]:\n",
8281
"```\n",
8382
"With that, you're ready to follow along."
@@ -97,23 +96,23 @@
9796
"This process (known as a \"kernel\") can be started by running the following command in your system shell:\n",
9897
"\n",
9998
"```\n",
100-
"$ jupyter notebook\n",
99+
"$ jupyter lab\n",
101100
"```\n",
102101
"\n",
103102
"This command will launch a local web server that will be visible to your browser.\n",
104103
"It immediately spits out a log showing what it is doing; that log will look something like this:\n",
105104
"\n",
106105
"```\n",
107-
"$ jupyter notebook\n",
108-
"[NotebookApp] Serving notebooks from local directory: /Users/jakevdp/PythonDataScienceHandbook\n",
109-
"[NotebookApp] 0 active kernels \n",
110-
"[NotebookApp] The IPython Notebook is running at: http://localhost:8888/\n",
111-
"[NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).\n",
106+
"$ jupyter lab\n",
107+
"[ServerApp] Serving notebooks from local directory: /Users/jakevdp/PythonDataScienceHandbook\n",
108+
"[ServerApp] Jupyter Server 1.4.1 is running at:\n",
109+
"[ServerApp] http://localhost:8888/lab?token=dd852649\n",
110+
"[ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).\n",
112111
"```\n",
113112
"\n",
114113
"Upon issuing the command, your default browser should automatically open and navigate to the listed local URL;\n",
115114
"the exact address will depend on your system.\n",
116-
"If the browser does not open automatically, you can open a window and manually open this address (*http://localhost:8888/* in this example)."
115+
"If the browser does not open automatically, you can open a window and manually open this address (*http://localhost:8888/lab/* in this example)."
117116
]
118117
},
119118
{

notebooks_v2/01.00-IPython-Beyond-Normal-Python.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jupyter:
3232

3333

3434
There are many options for development environments for Python, and I'm often asked which one I use in my own work.
35-
My answer sometimes surprises people: my preferred environment is [IPython](http://ipython.org/) plus a text editor (in my case, Emacs or Atom depending on my mood).
35+
My answer sometimes surprises people: my preferred environment is [IPython](http://ipython.org/) plus a text editor (in my case, Emacs or VSCode depending on my mood).
3636
IPython (short for *Interactive Python*) was started in 2001 by Fernando Perez as an enhanced Python interpreter, and has since grown into a project aiming to provide, in Perez's words, "Tools for the entire life cycle of research computing."
3737
If Python is the engine of our data science task, you might think of IPython as the interactive control panel.
3838

@@ -63,11 +63,10 @@ Start by launching the IPython interpreter by typing **``ipython``** on the comm
6363

6464
Once you do this, you should see a prompt like the following:
6565
```
66-
IPython 4.0.1 -- An enhanced Interactive Python.
67-
? -> Introduction and overview of IPython's features.
68-
%quickref -> Quick reference.
69-
help -> Python's own help system.
70-
object? -> Details about 'object', use 'object??' for extra details.
66+
Python 3.9.2 (v3.9.2:1a79785e3e, Feb 19 2021, 09:06:10)
67+
Type 'copyright', 'credits' or 'license' for more information
68+
IPython 7.21.0 -- An enhanced Interactive Python. Type '?' for help.
69+
7170
In [1]:
7271
```
7372
With that, you're ready to follow along.
@@ -83,23 +82,23 @@ Though the IPython notebook is viewed and edited through your web browser window
8382
This process (known as a "kernel") can be started by running the following command in your system shell:
8483

8584
```
86-
$ jupyter notebook
85+
$ jupyter lab
8786
```
8887

8988
This command will launch a local web server that will be visible to your browser.
9089
It immediately spits out a log showing what it is doing; that log will look something like this:
9190

9291
```
93-
$ jupyter notebook
94-
[NotebookApp] Serving notebooks from local directory: /Users/jakevdp/PythonDataScienceHandbook
95-
[NotebookApp] 0 active kernels
96-
[NotebookApp] The IPython Notebook is running at: http://localhost:8888/
97-
[NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
92+
$ jupyter lab
93+
[ServerApp] Serving notebooks from local directory: /Users/jakevdp/PythonDataScienceHandbook
94+
[ServerApp] Jupyter Server 1.4.1 is running at:
95+
[ServerApp] http://localhost:8888/lab?token=dd852649
96+
[ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
9897
```
9998

10099
Upon issuing the command, your default browser should automatically open and navigate to the listed local URL;
101100
the exact address will depend on your system.
102-
If the browser does not open automatically, you can open a window and manually open this address (*http://localhost:8888/* in this example).
101+
If the browser does not open automatically, you can open a window and manually open this address (*http://localhost:8888/lab/* in this example).
103102

104103

105104
<!--NAVIGATION-->

notebooks_v2/01.01-Help-And-Documentation.ipynb

Lines changed: 48 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,8 @@
6565
"In [1]: help(len)\n",
6666
"Help on built-in function len in module builtins:\n",
6767
"\n",
68-
"len(...)\n",
69-
" len(object) -> integer\n",
70-
" \n",
71-
" Return the number of items of a sequence or mapping.\n",
68+
"len(obj, /)\n",
69+
" Return the number of items in a container.\n",
7270
"```\n",
7371
"\n",
7472
"Depending on your interpreter, this information may be displayed as inline text, or in some separate pop-up window."
@@ -82,13 +80,9 @@
8280
"\n",
8381
"```ipython\n",
8482
"In [2]: len?\n",
85-
"Type: builtin_function_or_method\n",
86-
"String form: <built-in function len>\n",
87-
"Namespace: Python builtin\n",
88-
"Docstring:\n",
89-
"len(object) -> integer\n",
90-
"\n",
91-
"Return the number of items of a sequence or mapping.\n",
83+
"Signature: len(obj, /)\n",
84+
"Docstring: Return the number of items in a container.\n",
85+
"Type: builtin_function_or_method\n",
9286
"```"
9387
]
9488
},
@@ -101,9 +95,9 @@
10195
"```ipython\n",
10296
"In [3]: L = [1, 2, 3]\n",
10397
"In [4]: L.insert?\n",
104-
"Type: builtin_function_or_method\n",
105-
"String form: <built-in method insert of list object at 0x1024b8ea8>\n",
106-
"Docstring: L.insert(index, object) -- insert object before index\n",
98+
"Signature: L.insert(index, object, /)\n",
99+
"Docstring: Insert object before index.\n",
100+
"Type: builtin_function_or_method\n",
107101
"```\n",
108102
"\n",
109103
"or even objects themselves, with the documentation from their type:\n",
@@ -113,9 +107,11 @@
113107
"Type: list\n",
114108
"String form: [1, 2, 3]\n",
115109
"Length: 3\n",
116-
"Docstring:\n",
117-
"list() -> new empty list\n",
118-
"list(iterable) -> new list initialized from iterable's items\n",
110+
"Docstring: \n",
111+
"Built-in mutable sequence.\n",
112+
"\n",
113+
"If no argument is given, the constructor creates a new empty list.\n",
114+
"The argument must be an iterable if specified.\n",
119115
"```"
120116
]
121117
},
@@ -145,10 +141,10 @@
145141
"\n",
146142
"```ipython\n",
147143
"In [7]: square?\n",
148-
"Type: function\n",
149-
"String form: <function square at 0x103713cb0>\n",
150-
"Definition: square(a)\n",
151-
"Docstring: Return the square of a.\n",
144+
"Signature: square(a)\n",
145+
"Docstring: Return the square of a.\n",
146+
"File: <ipython-input-6>\n",
147+
"Type: function\n",
152148
"```\n",
153149
"\n",
154150
"This quick access to documentation via docstrings is one reason you should get in the habit of always adding such inline documentation to the code you write!"
@@ -164,13 +160,13 @@
164160
"\n",
165161
"```ipython\n",
166162
"In [8]: square??\n",
167-
"Type: function\n",
168-
"String form: <function square at 0x103713cb0>\n",
169-
"Definition: square(a)\n",
170-
"Source:\n",
163+
"Signature: square(a)\n",
164+
"Source: \n",
171165
"def square(a):\n",
172-
" \"Return the square of a\"\n",
166+
" \"\"\"Return the square of a.\"\"\"\n",
173167
" return a ** 2\n",
168+
"File: <ipython-input-6>\n",
169+
"Type: function\n",
174170
"```\n",
175171
"\n",
176172
"For simple functions like this, the double question-mark can give quick insight into the under-the-hood details."
@@ -186,13 +182,9 @@
186182
"\n",
187183
"```ipython\n",
188184
"In [9]: len??\n",
189-
"Type: builtin_function_or_method\n",
190-
"String form: <built-in function len>\n",
191-
"Namespace: Python builtin\n",
192-
"Docstring:\n",
193-
"len(object) -> integer\n",
194-
"\n",
195-
"Return the number of items of a sequence or mapping.\n",
185+
"Signature: len(obj, /)\n",
186+
"Docstring: Return the number of items in a container.\n",
187+
"Type: builtin_function_or_method\n",
196188
"```\n",
197189
"\n",
198190
"Using ``?`` and/or ``??`` gives a powerful and quick interface for finding information about what any Python function or module does."
@@ -220,18 +212,20 @@
220212
"\n",
221213
"```ipython\n",
222214
"In [10]: L.<TAB>\n",
223-
"L.append L.copy L.extend L.insert L.remove L.sort \n",
224-
"L.clear L.count L.index L.pop L.reverse \n",
215+
" append() count insert reverse \n",
216+
" clear extend pop sort \n",
217+
" copy index remove \n",
225218
"```\n",
226219
"\n",
227220
"To narrow-down the list, you can type the first character or several characters of the name, and the Tab key will find the matching attributes and methods:\n",
228221
"\n",
229222
"```ipython\n",
230223
"In [10]: L.c<TAB>\n",
231-
"L.clear L.copy L.count \n",
224+
" clear() count()\n",
225+
" copy() \n",
232226
"\n",
233227
"In [10]: L.co<TAB>\n",
234-
"L.copy L.count \n",
228+
" copy() count()\n",
235229
"```\n",
236230
"\n",
237231
"If there is only a single option, pressing the Tab key will complete the line for you.\n",
@@ -247,11 +241,13 @@
247241
"\n",
248242
"```ipython\n",
249243
"In [10]: L._<TAB>\n",
250-
"L.__add__ L.__gt__ L.__reduce__\n",
251-
"L.__class__ L.__hash__ L.__reduce_ex__\n",
244+
" __add__ __delattr__ __eq__ \n",
245+
" __class__ __delitem__ __format__()\n",
246+
" __class_getitem__() __dir__() __ge__ >\n",
247+
" __contains__ __doc__ __getattribute__ \n",
252248
"```\n",
253249
"\n",
254-
"For brevity, we've only shown the first couple lines of the output.\n",
250+
"For brevity, we've only shown the first few columns of the output.\n",
255251
"Most of these are Python's special double-underscore methods (often nicknamed \"dunder\" methods)."
256252
]
257253
},
@@ -265,23 +261,22 @@
265261
"Here we'll use it to find all possible imports in the ``itertools`` package that start with ``co``:\n",
266262
"```\n",
267263
"In [10]: from itertools import co<TAB>\n",
268-
"combinations compress\n",
269-
"combinations_with_replacement count\n",
264+
" combinations() compress()\n",
265+
" combinations_with_replacement() count()\n",
270266
"```\n",
271267
"Similarly, you can use tab-completion to see which imports are available on your system (this will change depending on which third-party scripts and modules are visible to your Python session):\n",
272268
"```\n",
273269
"In [10]: import <TAB>\n",
274-
"Display all 399 possibilities? (y or n)\n",
275-
"Crypto dis py_compile\n",
276-
"Cython distutils pyclbr\n",
277-
"... ... ...\n",
278-
"difflib pwd zmq\n",
270+
" abc anyio \n",
271+
" activate_this appdirs \n",
272+
" aifc appnope >\n",
273+
" antigravity argon2 \n",
279274
"\n",
280275
"In [10]: import h<TAB>\n",
281-
"hashlib hmac http \n",
282-
"heapq html husl \n",
283-
"```\n",
284-
"(Note that for brevity, I did not print here all 399 importable packages and modules on my system.)"
276+
" hashlib html \n",
277+
" heapq http \n",
278+
" hmac \n",
279+
"```"
285280
]
286281
},
287282
{
@@ -311,12 +306,12 @@
311306
"We can search for it this way:\n",
312307
"\n",
313308
"```ipython\n",
314-
"In [10]: str.*find*?\n",
309+
"In [11]: str.*find*?\n",
315310
"str.find\n",
316311
"str.rfind\n",
317312
"```\n",
318313
"\n",
319-
"I find this type of flexible wildcard search can be very useful for finding a particular command when getting to know a new package or reacquainting myself with a familiar one."
314+
"I find this type of flexible wildcard search can be useful for finding a particular command when getting to know a new package or reacquainting myself with a familiar one."
320315
]
321316
},
322317
{

0 commit comments

Comments
 (0)