Skip to content

Commit df2af64

Browse files
rsoklpetarmhg
andauthored
Some more changes (#167)
* Jupyter Notebooks: fix typos; fix broken plot * Update discussion of IDEs and improve formatting * Recommend PyLance extension instead of pyright. Closes #162 * update changelog and copyright date * add discussion board link * one line per sentence * Update Python/Module1_GettingStartedWithPython/Getting_Started_With_IDEs_and_Notebooks.md Co-authored-by: Petar Griggs <petargriggs@gmail.com> * Update Python/Module1_GettingStartedWithPython/Getting_Started_With_IDEs_and_Notebooks.md Co-authored-by: Petar Griggs <petargriggs@gmail.com> * Update Python/Module1_GettingStartedWithPython/Getting_Started_With_IDEs_and_Notebooks.md Co-authored-by: Petar Griggs <petargriggs@gmail.com> * Update Python/Module1_GettingStartedWithPython/Getting_Started_With_IDEs_and_Notebooks.md Co-authored-by: Petar Griggs <petargriggs@gmail.com> * Update Python/Module1_GettingStartedWithPython/Getting_Started_With_IDEs_and_Notebooks.md Co-authored-by: Petar Griggs <petargriggs@gmail.com> * Update Python/Module5_OddsAndEnds/Writing_Good_Code.md Co-authored-by: Petar Griggs <petargriggs@gmail.com> * Update Python/Module1_GettingStartedWithPython/Getting_Started_With_IDEs_and_Notebooks.md Co-authored-by: Petar Griggs <petargriggs@gmail.com> Co-authored-by: Petar Griggs <petargriggs@gmail.com>
1 parent b6fa1f3 commit df2af64

File tree

7 files changed

+78
-28
lines changed

7 files changed

+78
-28
lines changed

Python/Module1_GettingStartedWithPython/Getting_Started_With_IDEs_and_Notebooks.md

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,39 +39,49 @@ First and foremost, a good IDE will provide a text editor that will:
3939

4040
An IDE also often provides debugging tools so that you can test your code; it will also typically interface with version-control software, like Git, so that you can keep track of versions of your code as you modify it. We will not discuss these useful, but more advanced features here.
4141

42-
### Recommended IDEs
42+
## Recommended IDEs
4343
There are many excellent IDEs that can be configured to work well with Python. Two IDEs that we endorse are:
4444

45-
[PyCharm](https://www.jetbrains.com/pycharm/download): A powerful IDE dedicated to Python.
45+
### PyCharm
46+
47+
[PyCharm](https://www.jetbrains.com/pycharm/download) is a powerful and highly-polished IDE dedicated to developing Python code.
4648

4749
**Pros**
4850

49-
- works well out-of-the-box
50-
- long-supported by professionals and thus is very reliable
51-
- highly configurable
52-
- fully-featured, with an excellent debugger, context-dependent "intellisense", type-inference, and more
53-
- the free "community version" is extremely robust and feature-rich.
51+
- Works well out-of-the-box.
52+
- Long-supported by professionals and thus is very reliable.
53+
- Highly configurable.
54+
- Fully-featured, with an excellent debugger, context-dependent "intellisense", type-inference, and more.
55+
- The free "community version" is extremely robust and feature-rich.
56+
- Generally provides an extremely high-quality and responsive experience for doing Python development.
5457

5558
**Cons**
5659

57-
- can be resource-heavy, especially for a laptop
58-
- may be overwhelming to new users (but has good documentation and tutorials)
59-
- Jupyter notebook support requires the premium version of PyCharm, making it inaccessible to newcomers
60+
- Can be resource-heavy, especially for a laptop.
61+
- May be overwhelming to new users (but has good documentation and tutorials).
62+
- Jupyter notebook support requires the premium version of PyCharm, making it inaccessible to newcomers.
6063

61-
[Visual Studio Code](https://code.visualstudio.com/) with the [Python extension](https://code.visualstudio.com/docs/languages/python): A lightweight, highly customizable IDE.
64+
### Visual Studio Code
65+
66+
[Visual Studio Code](https://code.visualstudio.com/) (with the [Python extension](https://code.visualstudio.com/docs/languages/python)) is a lightweight, highly customizable IDE that works with many different languages.
67+
68+
Note: if you decide to use VSCode to do Python development, it is highly recommended that you install Microsoft's [PyLance](https://marketplace.visualstudio.com/items?itemName=ms-python.vscode-pylance)
69+
extension.
70+
This adds many useful features to the IDE that will make writing Python code a more delightful experience.
6271

6372
**Pros**
6473

65-
- lightweight and elegant
66-
- completely free
67-
- works with many different languages, so you only need to familiarize yourself with one IDE if you are a polyglot programmer
68-
- a huge number of extensions can be downloaded to add functionality to the editor; these are created by a large community of open-source developers.
69-
- [has native support for Jupyter notebooks](https://code.visualstudio.com/docs/python/jupyter-support), meaning that you get VSCode's intellisense, debugger, and ability to inspect variables, all in a notebook.
74+
- Lightweight and elegant.
75+
- Completely free.
76+
- Works with many different languages, so you only need to familiarize yourself with one IDE if you are a polyglot programmer.
77+
- Offers a huge number of extensions that can be downloaded to add functionality to the editor; these are created by a large community of open-source developers.
78+
- [Has native support for Jupyter notebooks](https://code.visualstudio.com/docs/python/jupyter-support), meaning that you get VSCode's intellisense, debugger, and ability to inspect variables, all in a notebook.
79+
- Provides incredibly robust [remote coding](https://code.visualstudio.com/docs/remote/remote-overview) and [collaborative coding](https://visualstudio.microsoft.com/services/live-share/) capabilities.
7080

7181
**Cons**
7282

73-
- configuring VSCode for python development can have a moderate learning curve for newcomers
74-
- many features, like context-aware intellisense and type-inference, are simply more polished and powerful in PyCharm
83+
- Configuring VSCode for Python development can have a moderate learning curve for newcomers.
84+
- Some features, like context-aware intellisense and type-inference, are simply more polished and powerful in PyCharm.
7585

7686

7787
<div class="alert alert-info">

Python/Module1_GettingStartedWithPython/Jupyter_Notebooks.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,24 @@ You should be all set once you have followed the prompts and the installation ha
5252
Note that you will need to repeat this process if you [create a new conda environment](https://www.pythonlikeyoumeanit.com/Module1_GettingStartedWithPython/Installing_Python.html#A-Brief-Introduction-to-Conda-Environments) with IPython/Jupter installed in it.
5353
</div>
5454

55-
In recent years, the Jupyter Notebook has become a massively popular tool for doing research-oriented work in Python and other languages alike. Its emergence marked a paradigm shift in the way data science is conducted.
55+
In recent years, the Jupyter Notebook has become a massively popular tool for doing research-oriented work in Python and other languages alike.
56+
Its emergence marked a paradigm shift in the way data science is conducted.
5657

57-
A Jupyter notebook is similar to the IPython console, but, instead of only being able to work with a single line of code at a time, you can easily edit and re-execute *any* code that had been written in a notebook. Furthermore, you can save a notebook, and thus return to it later. Additionally, a notebook provides many terrific features. For instance, you can embed visualizations of data within a notebook, and write blocks of nicely-formatted text (using the [Markdown syntax](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet)), for presenting and explaining the contents of the notebook.
58+
A Jupyter notebook is similar to the IPython console, but, instead of only being able to work with a single line of code at a time, you can easily edit and re-execute *any* code that had been written in a notebook. Furthermore, you can save a notebook, and thus return to it later.
59+
Additionally, a notebook provides many terrific features. For instance, you can embed visualizations of data within a notebook, and write blocks of nicely-formatted text (using the [Markdown syntax](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet)), for presenting and explaining the contents of the notebook.
5860

5961
In this way, the Jupyter Notebook stands out as an excellent tool for many practical applications. You could work on a notebook while you are working through sections of this website, for instance, testing out snippets of code, and answering reading-comprehension questions as you proceed through the text, and using markdown-headers to visually separate different portions of the notebook. When I do research, I am always creating Jupyter notebooks in which I write code that analyzes data, I plot various results, presented in different ways, and I write detailed markdown-text blocks to document my work. The end result is something that I can share with my labmates, and easily revisit months later without having to struggle to recall what I had done.
6062

6163
## Jupyter Lab
62-
[Jupyter lab](https://jupyterlab.readthedocs.io/) is a new web interface from Project Jupyter that provides a rich web-based interface for managing and running Jupyter notebooks, console terminals, and text editors, all within your browser. Among its useful features and polished user interface - compared to that a Jupyter notebook server - Jupyter lab provides moveable panes for viewing data, images, and code output apart from the rest of the notebook. This is facilitates effective data science work flows.
64+
[Jupyter lab](https://jupyterlab.readthedocs.io/) is a new web interface from Project Jupyter that provides a rich web-based interface for managing and running Jupyter notebooks, console terminals, and text editors, all within your browser.
65+
Among its useful features and polished user interface, Jupyter lab provides moveable panes for viewing data, images, and code output apart from the rest of the notebook.
66+
This is facilitates effective data science work flows.
6367

6468
It is recommended that you peruse the [Jupyter lab documentation](https://jupyterlab.readthedocs.io/en/stable/getting_started/overview.html) to get a feel for all of its added capabilities.
6569

6670

67-
The following instructions are laid out for running a Jupyter notebook server. That being said, the process for running a Jupyter lab server and working with notebooks therein is nearly identical. Both Jupyter notebook and Jupyter lab should already be [installed via Anaconda](https://www.pythonlikeyoumeanit.com/Module1_GettingStartedWithPython/Installing_Python.html).
71+
The following instructions are laid out for running a Jupyter notebook server. That being said, the process for running a Jupyter lab server and working with notebooks therein is nearly identical.
72+
Both Jupyter notebook and Jupyter lab should already be [installed via Anaconda](https://www.pythonlikeyoumeanit.com/Module1_GettingStartedWithPython/Installing_Python.html).
6873

6974

7075
## Running a Notebook Server & Creating a Notebook
@@ -133,7 +138,7 @@ import numpy as np
133138
import matplotlib.pyplot as plt
134139

135140
# this tells Jupyter to embed matplotlib plots in the notebook
136-
%matplotlib notebook
141+
%matplotlib inline
137142
```
138143

139144
```python

Python/Module5_OddsAndEnds/Writing_Good_Code.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,10 @@ This saves us the trouble of having to run our code, hit an error, read through
440440

441441
It does not take long to experience the benefits of type-hinting through your IDE. This both accelerates your coding by informing you of the object types that you are working with on the fly, and helps to expose oversights in your code as soon as they are made.
442442

443-
Finally, it is also worthwhile to highlight two projects, [mypy](http://mypy-lang.org/) and [pyright](https://github.com/microsoft/pyright), which are used to perform static type-checking on your code based on your type-hints. That is, mypy and pyright will both automatically traverse your code and find potential bugs by identifying type conflicts in your code (e.g. trying to capitalize an integer) by checking their annotated and inferred types. These tools are especially useful for large-scale code bases. Companies like Dropbox and Microsoft make keen use of static type-checking to identify inconsistencies in their code without having to hit runtime errors. Keep mypy, pyright, and other type-checking utilities in mind as you mature as a Python developer and find yourself working on projects of growing complexity. If you are using [VSCode as your IDE](https://www.pythonlikeyoumeanit.com/Module1_GettingStartedWithPython/Getting_Started_With_IDEs_and_Notebooks.html), you can install the [pyright vscode extension](https://marketplace.visualstudio.com/items?itemName=ms-pyright.pyright) to leverage type checking within your IDE.
443+
Finally, it is also worthwhile to highlight two projects, [mypy](http://mypy-lang.org/) and [pyright](https://github.com/microsoft/pyright), which are used to perform static type-checking on your code based on your type-hints.
444+
That is, mypy and pyright will both automatically traverse your code and find potential bugs by identifying type conflicts in your code (e.g. trying to capitalize an integer) by checking their annotated and inferred types.
445+
These tools are especially useful for large-scale code bases. Companies like Dropbox and Microsoft make keen use of static type-checking to identify inconsistencies in their code without having to hit runtime errors. Keep mypy, pyright, and other type-checking utilities in mind as you mature as a Python developer and find yourself working on projects of growing complexity.
446+
If you are using [VSCode as your IDE](https://www.pythonlikeyoumeanit.com/Module1_GettingStartedWithPython/Getting_Started_With_IDEs_and_Notebooks.html), you can install the [PyLance VSCode extension](https://marketplace.visualstudio.com/items?itemName=ms-python.vscode-pylance) to leverage pyright's type checking within your IDE.
444447
<!-- #endregion -->
445448

446449
<div class="alert alert-info">

Python/changes.rst

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,29 @@ Changelog
55
This is a record of all past PLYMI releases and what went into them,
66
in reverse chronological order.
77

8+
9+
----------
10+
2021-01-30
11+
----------
12+
13+
Updated the discussion of `computing pairwise differences <https://www.pythonlikeyoumeanit.com/Module3_IntroducingNumpy/Broadcasting.html#An-Advanced-Application-of-Broadcasting:-Pairwise-Distances>`_
14+
to account for potential floating-point edge cases that can produce "NaNs" as a result.
15+
16+
There is currently an incompatibility between `jedi 0.18.0` and IPython, which breaks autocompletion. See `here <https://github.com/ipython/ipython/issues/12740>`_ for more details.
17+
Added temporary callout boxes to the `informal introduction to Python <https://www.pythonlikeyoumeanit.com/Module1_GettingStartedWithPython/Informal_Intro_Python.html>`_ and to
18+
the `introduction to Jupyter notebooks <https://www.pythonlikeyoumeanit.com/Module1_GettingStartedWithPython/Jupyter_Notebooks.html>`_, which instruct readers to remedy this by downgrading jedi.
19+
20+
Fixed a missing plot in the `introduction to Jupyter <https://www.pythonlikeyoumeanit.com/Module1_GettingStartedWithPython/Jupyter_Notebooks.html>`_ section.
21+
22+
Reformatted the `section on IDEs <https://www.pythonlikeyoumeanit.com/Module1_GettingStartedWithPython/Getting_Started_With_IDEs_and_Notebooks.html>`_ and added a description of PyLance.
23+
24+
Add link to `PLYMI's discussion board <https://github.com/rsokl/Learning_Python/discussions>`_.
25+
826
----------
927
2021-01-24
1028
----------
1129

12-
Added brief discussion on semantic versioning. Thanks `@samaocarpenter <https://github.com/samaocarpenter>`_!
30+
Added a brief `discussion of Python versions <https://www.pythonlikeyoumeanit.com/Module1_GettingStartedWithPython/GettingStartedWithPython.html#Understanding-Different-Versions-of-Python>`_. Thanks `@samaocarpenter <https://github.com/samaocarpenter>`_!
1331

1432
Fixed typos `#160 <https://github.com/rsokl/Learning_Python/pull/160>`_ `#158 <https://github.com/rsokl/Learning_Python/pull/158>`_
1533
`#155 <https://github.com/rsokl/Learning_Python/pull/155>`_

Python/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959

6060
# General information about the project.
6161
project = "Python Like You Mean It"
62-
copyright = "2019, Ryan Soklaski"
62+
copyright = "2021, Ryan Soklaski"
6363
author = "Ryan Soklaski"
6464
html_title = "Python Like You Mean It"
6565

Python/index.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ What this is
1212
------------
1313
Python Like You Mean It (PLYMI) is a free resource for learning the basics of Python & NumPy, and moreover, becoming a competent Python user. The features of the Python language that are emphasized here were chosen to help those who are particularly interested in STEM applications (data analysis, machine learning, numerical work, etc.).
1414

15-
I want this to be a lean, one-stop resource for learning the essentials of Python from scratch. The reader will begin by learning about what Python is and what installing Python even means, and will hopefully walk away with a solid understanding of a substantial core of the language and its premiere numerical library, NumPy. I am also placing an emphasis on best practices throughout this site and am teaching to the latest version of Python (version 3.8, as of writing this).
15+
I want this to be a lean, one-stop resource for learning the essentials of Python from scratch. The reader will begin by learning about what Python is and what installing Python even means, and will hopefully walk away with a solid understanding of a substantial core of the language and its premiere numerical library, NumPy. I am also placing an emphasis on best practices throughout this site and am teaching to the latest version of Python (version 3.9, as of writing this).
1616

1717

1818
What this isn't
@@ -32,10 +32,18 @@ Python shouldn't be *too* easy
3232
Python is a relatively easy language to pick up, and it doesn't require much rigor to make code work. Unfortunately, this means that there are many Python users out there who know enough to just get by, but lack a sound understanding of the language. You don't want to get caught in the "know enough Python to be dangerous" zone; therein lies complacency, stagnation, and the genesis of a lot of bad code. You've got to Python like you mean it!
3333

3434

35+
Join Our Discussion Board
36+
-------------------------
37+
`Join the PLYMI community <https://github.com/rsokl/Learning_Python/discussions>`_ to ask questions, recommend new content, or to just say hello!
38+
39+
(A note to `BWSI students <https://beaverworks.ll.mit.edu/CMS/bw/bwsi>`_: please stick to your class' piazza board for posting questions)
40+
41+
3542
PLYMI is on GitHub
3643
------------------
3744
If you have questions about the reading, think that you have spotted some mistakes, or would like to contribute to PLYMI, please visit `our GitHub page <https://github.com/rsokl/Learning_Python>`_. You will need to create a GitHub account in order to post an issue; this process is free and easy. We would love for you to join us to discuss the website!
3845

46+
3947
Contributors
4048
------------
4149
The following people made significant contributions to PLYMI, adding problems with worked solutions and valuable feedback on the text:

Python/intro.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ What this is
1212
------------
1313
Python Like You Mean It (PLYMI) is a free resource for learning the basics of Python & NumPy, and moreover, becoming a competent Python user. The features of the Python language that are emphasized here were chosen to help those who are particularly interested in STEM applications (data analysis, machine learning, numerical work, etc.).
1414

15-
I want this to be a lean, one-stop resource for learning the essentials of Python from scratch. The reader will begin by learning about what Python is and what installing Python even means, and will hopefully walk away with a solid understanding of a substantial core of the language and its premiere numerical library, NumPy. I am also placing an emphasis on best practices throughout this site and am teaching to the latest version of Python (version 3.8, as of writing this).
15+
I want this to be a lean, one-stop resource for learning the essentials of Python from scratch. The reader will begin by learning about what Python is and what installing Python even means, and will hopefully walk away with a solid understanding of a substantial core of the language and its premiere numerical library, NumPy. I am also placing an emphasis on best practices throughout this site and am teaching to the latest version of Python (version 3.9, as of writing this).
1616

1717

1818
What this isn't
@@ -31,6 +31,12 @@ Python shouldn't be *too* easy
3131
------------------------------
3232
Python is a relatively easy language to pick up, and it doesn't require much rigor to make code work. Unfortunately, this means that there are many Python users out there who know enough to just get by, but lack a sound understanding of the language. You don't want to get caught in the "know enough Python to be dangerous" zone; therein lies complacency, stagnation, and the genesis of a lot of bad code. You've got to Python like you mean it!
3333

34+
Join Our Discussion Board
35+
-------------------------
36+
`Join the PLYMI community <https://github.com/rsokl/Learning_Python/discussions>`_ to ask questions, recommend new content, or to just say hello!
37+
38+
(A note to `BWSI students <https://beaverworks.ll.mit.edu/CMS/bw/bwsi>`_: please stick to your class' piazza board for posting questions)
39+
3440

3541
PLYMI is on GitHub
3642
------------------

0 commit comments

Comments
 (0)