Skip to content

Commit 85108ad

Browse files
committed
little things
1 parent 5a5d4c5 commit 85108ad

File tree

9 files changed

+47
-37
lines changed

9 files changed

+47
-37
lines changed

README.md

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,18 @@ you have programmed a lot in the past using some other language you
1111
probably want to read
1212
[the official tutorial](https://docs.python.org/3/tutorial/) instead.
1313

14-
This tutorial uses Python 3, and you need Python 3 to be able to run the
15-
example code yourself. Python 2 is getting outdated all the time,
16-
and more and more projects are moving to Python 3. There are a few
17-
popular libraries that don't support Python 3 that well at the time of
18-
writing this, but you don't need to worry about that just yet. They
19-
will probably support Python 3 by the time you've learned the basics
20-
and you may actually need them.
14+
This tutorial was written in Python 3, and you need Python 3 or newer to
15+
be able to run the example code yourself. Python 2 is getting outdated
16+
all the time, and more and more projects are moving to Python 3. There
17+
are a few popular libraries that don't support Python 3 that well at the
18+
time of writing this, but you don't need to worry about that just yet.
19+
They will probably support Python 3 by the time you've learned the
20+
basics and you may actually need them.
2121

2222
I have tested most of the code in this tutorial on Python 3.4, but
23-
everything should also work on any Python 3 version or newer.
23+
everything should also work on Python 3.2 and all newer Pythons.
2424

25-
Here's a list of chapters in this tutorial. Read them one by one in the
26-
order they are listed. **If you jump to a chapter without reading and
27-
understanding everything before it, you may have hard time understanding
28-
the chapter you're trying to read.** However, the chapters are mostly
29-
independent from each other, so you can also use this tutorial together
30-
with other tutorials.
25+
## List of contents
3126

3227
1. [What is programming?](what-is-programming.md)
3328
2. [Installing Python](installing-python.md)

exceptions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ all of these errors. You don't need to remember this tree, running
401401
`help('builtins')` should display a larger tree that this is a part of.
402402

403403
There's also a few exceptions that are not in this tree like SystemExit
404-
and KeyboardInterrupt, but most of the time you shouldn't catch them.
404+
and KeyboardInterrupt, but most of the time we shouldn't catch them.
405405
Catching Exception doesn't catch them either.
406406

407407
## Summary

getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ Powers are calculated before `*` and `/`, but after `()`.
206206
## Summary
207207

208208
- Errors don't matter.
209-
- You can enter any Python commands to the interactive `>>>` prompt, and
209+
- We can enter any Python commands to the interactive `>>>` prompt, and
210210
it will echo back the result.
211211
- Pieces of text starting with a `#` are comments.
212212
- `+`, `-`, `*` and `/` work in Python just like in math.

handy-stuff-strings.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ If you need to know more about formatting I recommend reading
321321

322322
![Slicing](images/slicing3.png)
323323

324-
- Indexing returns one character of a string. Remember that you don't
324+
- Indexing returns one character of a string. Remember that we don't
325325
need a `:` with indexing. The indexes work like this:
326326

327327
![Indexing](images/indexing3.png)

if.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ else:
280280
If it doesn't, write it to a file and run that file.
281281
- Indentation is important in Python.
282282
- Indented code under an if statement runs if the condition is true.
283-
- You can also add an else statement. Indented code under it will run
283+
- We can also add an else statement. Indented code under it will run
284284
if the code under the if statement does not run.
285285
- elif is short for else if.
286286

images/modules.png

112 KB
Loading

modules.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ OSX.
4646
You'll see a bunch of files and a few directories in the folder
4747
that opens:
4848

49-
**TODO: Add a screenshot.**
49+
![My Python's modules.](images/modules.png)
5050

5151
All of these `.py` files can be imported like we just imported
5252
`random.py`. In random.py, there's a like like `randint = something`,
@@ -175,7 +175,7 @@ module in many files, so it gets imported multiple times. If
175175
Python would reload the module every time it's imported,
176176
dividing code to multiple files would make the code run slower.
177177

178-
If you want to load the module again, just exit out of Python and
178+
If we need to load the module again we can just exit out of Python and
179179
launch it again.
180180

181181
## Brief overview of the standard library
@@ -473,16 +473,16 @@ section at the bottom.
473473

474474
## Summary
475475

476-
- Most modules are files on your computer, but some of them are built
476+
- Most modules are files on our computers, but some of them are built
477477
in to Python. We can use modules in our projects by importing them,
478478
and after that using `modulename.variable` to get a variable from
479479
the module.
480480
- Some of the most commonly used modules are random, sys, math, time
481481
and os.
482482
- Avoid creating `.py` files that have the same name as a name of a
483483
module you want to use.
484-
- Python comes with many modules, and you can install even more modules
485-
if you want to.
484+
- Python comes with many modules, and we can install even more modules
485+
if we want to.
486486

487487
***
488488

using-functions.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Of course, `x = print('hello')` is useless compared to `print('hello')`
7777
because the print function always returns None and we can do `x = None`
7878
without any printing.
7979

80-
You can also print an empty line by calling print without any
80+
We can also print an empty line by calling print without any
8181
arguments:
8282

8383
```py
@@ -96,7 +96,7 @@ world
9696
>>>
9797
```
9898

99-
If you want to print a backslash, you need to **escape** it by typing
99+
If we want to print a backslash, we need to **escape** it by typing
100100
two backslashes:
101101

102102
[comment]: # (For some reason, GitHub's syntax highlighting doesn't)
@@ -106,8 +106,8 @@ two backslashes:
106106
hello\nworld
107107
>>>
108108

109-
You can also pass multiple arguments to the print function. Separate
110-
them with commas, and print will add spaces between them.
109+
We can also pass multiple arguments to the print function. We need to
110+
separate them with commas and print will add spaces between them.
111111

112112
```py
113113
>>> print("Hello", "World!")
@@ -139,7 +139,7 @@ screen and waited for me to type something. I typed hello and pressed
139139
Enter. Then input returned the hello I typed as a string and it was
140140
assigned to x.
141141

142-
You may want to add a space after the `:`, like this:
142+
Usually we want to add a space after the `:`, like this:
143143

144144
```py
145145
>>> x = input("Enter something: ") # now there's space between : and where i type

variables.md

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ without variables.
7171

7272
Variable names can be multiple characters long. They can contain
7373
uppercase characters, numbers and some other characters, but most of the
74-
time you should use simple, lowercase variable names. You can also use
74+
time we should use simple, lowercase variable names. You can also use
7575
underscores.
7676

7777
```py
@@ -97,7 +97,7 @@ Variable names are case-sensitive, like many other things in Python.
9797

9898
Python also has some words that cannot be used as variable names
9999
because they have a special meaning. They are called **keywords**, and
100-
you can run `help('keywords')` to see the full list if you want to.
100+
we can run `help('keywords')` to see the full list if we want to.
101101
We'll learn to use most of them later in this tutorial. Trying to use a
102102
keyword as a variable name causes a syntax error.
103103

@@ -146,7 +146,7 @@ This is not limited to integers.
146146
>>>
147147
```
148148

149-
Now you also understand why typing hello to the prompt didn't work in
149+
Now we also understand why typing hello to the prompt didn't work in
150150
the beginning of this tutorial. But we can assign something to a
151151
variable called hello and then type hello:
152152

@@ -174,7 +174,7 @@ False
174174
```
175175

176176
`a == 1` is the same as `(a == 1) == True`, but `a == 1` is more
177-
readable, so most of the time you shouldn't write `== True` anywhere.
177+
readable, so most of the time we shouldn't write `== True` anywhere.
178178

179179
```py
180180
>>> a = 1
@@ -213,14 +213,30 @@ This is because the prompt never echoes back None. That is handy,
213213
because many things result in None, and it would be annoying to see
214214
None coming up all the time.
215215

216-
If we want to see a None on the interactive prompt, we can use print:
216+
If we want to see a None on the interactive prompt, we can use print.
217217

218218
```py
219219
>>> print(thingy)
220220
None
221221
>>>
222222
```
223223

224+
Another confusing thing is that if we do something weird to None we get
225+
error messages that talk about NoneType object. The NoneType object they
226+
are talking about is always None.
227+
228+
```py
229+
>>> None.hello # None has no attribute 'hello'
230+
Traceback (most recent call last):
231+
File "<stdin>", line 1, in <module>
232+
AttributeError: 'NoneType' object has no attribute 'hello'
233+
>>> None() # None is not callable
234+
Traceback (most recent call last):
235+
File "<stdin>", line 1, in <module>
236+
TypeError: 'NoneType' object is not callable
237+
>>>
238+
```
239+
224240
## Other comparing operators
225241

226242
So far we've used `==`, but there are other operators also. At this
@@ -230,21 +246,20 @@ easy to learn.
230246
| Usage | Description | True examples |
231247
|-----------|-----------------------------------|-----------------------|
232248
| `a == b` | a is equal to b | `1 == 1` |
233-
| `a != b` | a is not equal to b | `1 == 2` |
249+
| `a != b` | a is not equal to b | `1 != 2` |
234250
| `a > b` | a is greater than b | `2 > 1` |
235251
| `a >= b` | a is greater than or equal to b | `2 >= 1`, `1 >= 1` |
236252
| `a < b` | a is less than b | `1 < 2` |
237253
| `a <= b` | a is less than or equal to b | `1 <= 2`, `1 <= 1` |
238254

239-
We can also combine multiple comparisons.
255+
We can also combine multiple comparisons. This table assumes that a and
256+
b are Booleans.
240257

241258
| Usage | Description | True example |
242259
|-----------|-------------------------------------------|-----------------------------------|
243260
| `a and b` | a is True and b is True | `1 == 1 and 2 == 2` |
244261
| `a or b` | a is True, b is True or they're both True | `False or 1 == 1`, `True or True` |
245262

246-
This table assumes that a and b are Booleans.
247-
248263
Another way to combine operations is chaining. For example, `a < b < c`
249264
does the same thing as `a < b and b < c`.
250265

0 commit comments

Comments
 (0)