8000 Fix bad console markup and raise exception in script · StudyCourse/pythonlearn@30c019b · GitHub
[go: up one dir, main page]

Skip to content

Commit 30c019b

Browse files
committed
Fix bad console markup and raise exception in script
1 parent 7eb1027 commit 30c019b

File tree

5 files changed

+9
-1024
lines changed

5 files changed

+9
-1024
lines changed

book/03-conditional.mkd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ true or false. The following examples use the operator `==`,
1414
which compares two operands and produces `True` if they are
1515
equal and `False` otherwise:
1616

17-
~~~~ {.python trinket}
17+
~~~~ {.python .trinket}
1818
>>> 5 == 5
1919
True
2020
>>> 5 == 6
2121
False
22+
{}
2223
~~~~
2324

2425
`True` and `False` are special values that belong

book/09-dictionaries.mkd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ avoid using it as a variable name.
2929
\index{dict function}
3030
\index{function!dict}
3131

32-
~~~~ {.python trinket}
32+
~~~~ {.python .trinket}
3333
>>> eng2sp = dict()
3434
>>> print(eng2sp)
3535
{}
@@ -186,7 +186,7 @@ for the letters that do appear.
186186

187187
Here is what the code might look like:
188188

189-
~~~~ {.python trinket}
189+
~~~~ {.python .trinket}
190190
word = 'brontosaurus'
191191
d = dict()
192192
for c in word:
@@ -229,7 +229,7 @@ a default value. If the key appears in the dictionary, `get`
229229
returns the corresponding value; otherwise it returns the default value.
230230
For example:
231231

232-
~~~~ {.python trinket}
232+
~~~~ {.python .trinket}
233233
>>> counts = { 'chuck' : 1 , 'annie' : 42, 'jan': 100}
234234
>>> print(counts.get('jan', 0))
235235
100

book/consoles.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
whole_string = x.group(1)
2020
arguments = x.group(1).split()
2121

22-
# print x
22+
# Check for errors
23+
if x and ('trinket' in arguments):
24+
raise Exception("Error: found 'trinket'; should be '.trinket' in " + line)
2325
# If open, include script
2426
if x and ('.trinket' in arguments) and ('.python' in arguments) :
2527
with open('trinket/console-trinket-script') as ts:

0 commit comments

Comments
 (0)
0