Skip to content

Commit 42f9da7

Browse files
committed
2 parents 013be0d + d26fbb5 commit 42f9da7

File tree

5 files changed

+62
-5
lines changed

5 files changed

+62
-5
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# generated html files
2+
html/

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ They will probably support Python 3 by the time you've learned the
2020
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 Python 3.2 and all newer Pythons.
23+
everything should also work on Python 3.3, 3.2 and all newer Pythons.
2424

2525
## List of contents
2626

TODO.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@
33
This tutorial is not complete. It still needs:
44

55
- range somewhere
6-
- Better lists chapter, also introduce tuples in it
76
- **More exercises and examples everywhere!**
8-
- explain bool(x) and why it matters
7+
- classes part 1:
8+
9+
<deniska> Akuli: I would probably add an example of refactoring
10+
a bunch of functions working with shared global data
11+
into a class because it's a pretty typical usecase
12+
913
- classes part 2
1014
- non-public `_variables` (maybe reading PEP-8 is enough to explain this?)
1115
- "singular" inheritance, inheritance of built-in classes
1216
- using super
13-
- no classes part 3 with multiple inheritance, it's not something people need
17+
- advise to avoid multiple inheritance
1418
- iterables and iterators: something most Python programmers need to be
1519
aware of
1620
- last chapter: "What should I do now?" links to other resources

loops.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ while True:
384384
print("I didn't know you to begin with.")
385385

386386
elif option == '4':
387-
if len(namelist) == 0: # len is short for length
387+
if namelist == []:
388388
print("I don't know anybody yet.")
389389
else:
390390
for name in namelist:

make-html.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import glob
2+
import shutil
3+
import os
4+
import sys
5+
import webbrowser
6+
7+
try:
8+
import mistune
9+
except ImportError:
10+
print("mistune isn't installed. You can install it like this:\n\n",
11+
" thispython -m pip install mistune", file=sys.stderr)
12+
sys.exit(1)
13+
14+
15+
def main():
16+
if os.path.exists('html'):
17+
if input("html exists. Do you want "
18+
"to remove it? [Y/n] ").upper() == 'N':
19+
print("Interrupt.")
20+
return
21+
if os.path.isdir('html'):
22+
shutil.rmtree('html')
23+
else:
24+
os.remove('html')
25+
os.mkdir('html')
26+
print("Generating HTML files...")
27+
for markdownfile in glob.glob('*.md'):
28+
htmlfile = os.path.join('html', markdownfile[:-3] + '.html')
29+
print(' ', markdownfile, '->', htmlfile)
30+
with open(markdownfile, 'r') as f1:
31+
with open(htmlfile, 'w') as f2:
32+
md = f1.read()
33+
md = md.replace('.md)', '.html)')
34+
html = mistune.markdown(md)
35+
print(html, file=f2)
36+
os.rename(os.path.join('html', 'README.html'),
37+
os.path.join('html', 'index.html'))
38+
shutil.copytree('images', os.path.join('html', 'images'))
39+
print()
40+
print("*********************")
41+
print()
42+
print("Ready! The files are in the html directory,")
43+
print("double-click html/index.html to read the tutorial.")
44+
print()
45+
if input("Do you want to view the tutorial now? [Y/n] ").upper() != 'N':
46+
print("Opening the tutorial...")
47+
webbrowser.open(os.path.join('html', 'index.html'))
48+
49+
50+
if __name__ == '__main__':
51+
main()

0 commit comments

Comments
 (0)