Skip to content

Commit 5c14594

Browse files
committed
drop support for old pythons
1 parent 4c220ea commit 5c14594

File tree

4 files changed

+30
-70
lines changed

4 files changed

+30
-70
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ or very little programming experience. If you have programmed a lot in
1212
the past using some other language you may want to read [the official
1313
tutorial](https://docs.python.org/3/tutorial/) instead.
1414

15-
You can use Python 3.3 or any newer Python with this tutorial. **Don't
15+
You can use Python 3.5 or any newer Python with this tutorial. **Don't
1616
use Python 2 because it's no longer supported.**
1717

1818
## List of contents

advanced/datatypes.md

Lines changed: 12 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -316,68 +316,25 @@ TypeError: unsupported operand type(s) for +: 'dict' and 'dict'
316316
>>>
317317
```
318318

319-
Dictionaries have an `update` method that adds everything from another
320-
dictionary into it. So we can merge dictionaries like this:
319+
Usually it's easiest to do this:
321320

322321
```python
323-
>>> merged = {}
324-
>>> merged.update({'a': 1, 'b': 2})
325-
>>> merged.update({'c': 3})
326-
>>> merged
327-
{'c': 3, 'b': 2, 'a': 1}
328-
>>>
329-
```
330-
331-
Or we can [write a function](../basics/defining-functions.md) like this:
332-
333-
```python
334-
>>> def merge_dicts(dictlist):
335-
... result = {}
336-
... for dictionary in dictlist:
337-
... result.update(dictionary)
338-
... return result
339-
...
340-
>>> merge_dicts([{'a': 1, 'b': 2}, {'c': 3}])
341-
{'c': 3, 'b': 2, 'a': 1}
342-
>>>
322+
>>> dict1 = {'a': 1, 'b': 2}
323+
>>> dict2 = {'c': 3}
324+
>>> {**dict1, **dict2}
325+
{'a': 1, 'b': 2, 'c': 3}
343326
```
344327

345-
Kind of like counting things, merging dictionaries is also a commonly
346-
needed thing and there's a class just for it in the `collections`
347-
module. It's called ChainMap:
328+
Dictionaries also have an `update` method that adds everything from another
329+
dictionary into it, and you can use that too. This was the most common way to
330+
do it before Python supported `{**dict1, **dict2}`.
348331

349332
```python
350-
>>> import collections
351-
>>> merged = collections.ChainMap({'a': 1, 'b': 2}, {'c': 3})
333+
>>> merged = {}
334+
>>> merged.update({'a': 1, 'b': 2})
335+
>>> merged.update({'c': 3})
352336
>>> merged
353-
ChainMap({'b': 2, 'a': 1}, {'c': 3})
354-
>>>
355-
```
356-
357-
Our `merged` is kind of like the Counter object we created earlier. It's
358-
not a dictionary, but it behaves like a dictionary.
359-
360-
```python
361-
>>> for key, value in merged.items():
362-
... print(key, value)
363-
...
364-
c 3
365-
b 2
366-
a 1
367-
>>> dict(merged)
368-
{'c': 3, 'b': 2, 'a': 1}
369-
>>>
370-
```
371-
372-
Starting with Python 3.5 it's possible to merge dictionaries like this.
373-
**Don't do this unless you are sure that no-one will need to run your
374-
code on Python versions older than 3.5.**
375-
376-
```python
377-
>>> first = {'a': 1, 'b': 2}
378-
>>> second = {'c': 3, 'd': 4}
379-
>>> {**first, **second}
380-
{'d': 4, 'c': 3, 'a': 1, 'b': 2}
337+
{'a': 1, 'b': 2, 'c': 3}
381338
>>>
382339
```
383340

basics/exceptions.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ it's usually better to use `sys.stderr` and `sys.exit`.
319319
## Exception hierarchy
320320

321321
Exceptions are organized like this. I made this tree with [this
322-
program](https://github.com/Akuli/classtree/) on Python 3.4. You may
322+
program](https://github.com/Akuli/classtree/) on Python 3.7. You may
323323
have more or less exceptions than I have if your Python is newer or
324324
older than mine, but they should be mostly similar.
325325

@@ -333,6 +333,7 @@ older than mine, but they should be mostly similar.
333333
├── BufferError
334334
├── EOFError
335335
├── ImportError
336+
│ └── ModuleNotFoundError
336337
├── LookupError
337338
│ ├── IndexError
338339
│ └── KeyError
@@ -357,7 +358,9 @@ older than mine, but they should be mostly similar.
357358
│ └── TimeoutError
358359
├── ReferenceError
359360
├── RuntimeError
360-
│ └── NotImplementedError
361+
│ ├── NotImplementedError
362+
│ └── RecursionError
363+
├── StopAsyncIteration
361364
├── StopIteration
362365
├── SyntaxError
363366
│ └── IndentationError

basics/modules.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ gave us?
2828

2929
```python
3030
>>> random
31-
<module 'random' from '/usr/lib/python3.4/random.py'>
31+
<module 'random' from '/usr/lib/python3.7/random.py'>
3232
>>>
3333
```
3434

3535
So it's a module, and it comes from a path... but what does
3636
all that mean?
3737

38-
Now open the folder that contains your `random.py` is. On my
39-
system it's `/usr/lib/python3.4`, but yours will probably be
38+
Now open the folder that contains your `random.py`. On my
39+
system it's `/usr/lib/python3.7`, but yours will probably be
4040
different. To open a folder in your file manager you can press
41-
Windows-R on Windows or Alt+F2 on most GNU/Linux distributions,
41+
Windows-R on Windows or Alt+F2 on most Linux distributions,
4242
and just type your path there. I don't have an up-to-date copy
4343
of OSX so unfortunately I have no idea what you need to do on
4444
OSX.
@@ -138,11 +138,11 @@ places that modules are searched from:
138138
<module 'sys' (built-in)>
139139
>>> sys.path
140140
['',
141-
'/usr/lib/python3.4',
142-
'/usr/lib/python3.4/plat-i386-linux-gnu',
143-
'/usr/lib/python3.4/lib-dynload',
144-
'/home/akuli/.local/lib/python3.4/site-packages',
145-
'/usr/local/lib/python3.4/dist-packages',
141+
'/usr/lib/python37.zip',
142+
'/usr/lib/python3.7',
143+
'/usr/lib/python3.7/lib-dynload',
144+
'/home/akuli/.local/lib/python3.7/site-packages',
145+
'/usr/local/lib/python3.7/dist-packages',
146146
'/usr/lib/python3/dist-packages']
147147
>>>
148148
```
@@ -234,9 +234,9 @@ hello
234234
>>>
235235
>>> # information about Python's version, behaves like a tuple
236236
>>> sys.version_info
237-
sys.version_info(major=3, minor=4, micro=2, releaselevel='final', serial=0)
238-
>>> sys.version_info[:3] # this is Python 3.4.2
239-
(3, 4, 2)
237+
sys.version_info(major=3, minor=7, micro=3, releaselevel='final', serial=0)
238+
>>> sys.version_info[:3] # this is Python 3.7.3
239+
(3, 7, 3)
240240
>>>
241241
>>> sys.exit() # exit out of Python
242242
```

0 commit comments

Comments
 (0)