Skip to content

Commit 3cd8881

Browse files
committed
partial rewrite of packaging your turn.
1 parent 3820b4f commit 3cd8881

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

your-turn/11-python-packages/readme.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,21 @@ Notice it created the empty `__init__.py` for you and the folder icon is slightl
4444

4545
## Add a feature
4646

47-
We'll add a couple of simple math methods to our calculator. Create another Python file in the folder called `math.py` and add an `add(x, y)` and `subtract(x, y)` pair of methods to `math.py`.
47+
We'll add a couple of simple math methods to our calculator. **Create another Python file** in the folder called `math.py` and add an `add(x, y)` and `subtract(x, y)` pair of methods to `math.py`.
4848

4949
To make importing it easier, add this line to `__init__.py`:
5050

5151
```python
5252
from . import math
5353
```
5454

55-
That means you can consume it by typing `import calcy` then calling `calcy.math.add(7, 11)`.
55+
That means you can consume it by typing `import calcy` then calling `calcy.math.add(7, 11)`. If you omit this, you'll have to type `import calcy.math` to use the library like this even if you have already typed `impot calcy`.
5656

5757
Use the Python Console in PyCharm to test this (it adds the necessary path adjustments to run the package). For example, when I run the Python console, I see this output prior to the `>>>` prompt.
5858

5959
```python
6060
import sys; print('Python %s on %s' % (sys.version, sys.platform))
61-
sys.path.extend(['/Users/mkennedy/Desktop/calcy_package'])
61+
sys.path.extend(['/Users/michaelkennedy/code/calcy_package'])
6262
```
6363

6464
This is PyCharm automatically extending the Python path. You do **not** need to do anything to make this happen. It's just PyCharm making life easy on us.
@@ -67,13 +67,12 @@ Now, in the console, here's one way to test it:
6767

6868
```python
6969
import calcy
70-
calcy.math.add(7, 5)
71-
12
70+
calcy.math.add(7, 5) # <-- outputs 12
7271
```
7372

7473
In this special environment, it should work.
7574

76-
## Include a setup
75+
## Include a pyproject.toml
7776

7877
It's great you can run your code locally. But for real packages, you'll need to be able to install it for consumers. To do this, we need a `setup.py`.
7978

Loading

0 commit comments

Comments
 (0)