Skip to content

Commit eafdcda

Browse files
committed
Website build
1 parent 9dc0e13 commit eafdcda

13 files changed

+534
-67
lines changed

0_introduction.html

Lines changed: 246 additions & 20 deletions
Large diffs are not rendered by default.

1_programs_in_files.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ <h3><span class="section-number">2.3.2. </span>Other forms of import<a class="he
285285
between to end points is now accessible as <a class="reference external" href="https://numpy.org/doc/stable/reference/generated/numpy.linspace.html#numpy.linspace" title="(in NumPy v1.19)"><code class="xref py py-func docutils literal notranslate"><span class="pre">np.linspace</span></code></a>.</p>
286286
<p>A second option is to import particular names from a module directly
287287
into the current namespace. For example, if we planned to use the
288-
fuctions <a class="reference external" href="https://docs.python.org/3/library/math.html#math.sin" title="(in Python v3.9)"><code class="xref py py-func docutils literal notranslate"><span class="pre">math.sin()</span></code></a> and <a class="reference external" href="https://docs.python.org/3/library/math.html#math.cos" title="(in Python v3.9)"><code class="xref py py-func docutils literal notranslate"><span class="pre">math.cos()</span></code></a> a lot in our script, we
288+
functions <a class="reference external" href="https://docs.python.org/3/library/math.html#math.sin" title="(in Python v3.9)"><code class="xref py py-func docutils literal notranslate"><span class="pre">math.sin()</span></code></a> and <a class="reference external" href="https://docs.python.org/3/library/math.html#math.cos" title="(in Python v3.9)"><code class="xref py py-func docutils literal notranslate"><span class="pre">math.cos()</span></code></a> a lot in our script, we
289289
might use the following import statement:</p>
290290
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">math</span> <span class="kn">import</span> <span class="n">sin</span><span class="p">,</span> <span class="n">cos</span>
291291
</pre></div>
@@ -620,7 +620,7 @@ <h2><span class="section-number">2.7. </span>Testing frameworks<a class="headerl
620620
the practical details of including tests in your code here.</p>
621621
<p>There are a number of Python packages which support code testing. The
622622
concepts are largely similar so rather than get bogged down in the
623-
details of multiple frameworks, we will introduce <a class="reference external" href="https://docs.pytest.org/en/latest/index.html" title="(in pytest v0.1.dev280+gf453460)"><span class="xref std std-doc">pytest</span></a>, which is one of the most widely used.</p>
623+
details of multiple frameworks, we will introduce <a class="reference external" href="https://docs.pytest.org/en/latest/index.html" title="(in pytest v0.1.dev285+ge8504e0)"><span class="xref std std-doc">pytest</span></a>, which is one of the most widely used.</p>
624624
<div class="section" id="pytest-tests">
625625
<h3><span class="section-number">2.7.1. </span>Pytest tests<a class="headerlink" href="#pytest-tests" title="Permalink to this headline"></a></h3>
626626
<p>A Pytest test is simply a function whose name starts with <code class="xref py py-obj docutils literal notranslate"><span class="pre">test_</span></code>. In

3_style.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ <h2><span class="section-number">4.4. </span>Names<a class="headerlink" href="#n
277277
to use capitals, when underscores and so on. This is covered by PEP 8
278278
and we reproduce some of the important rules below. The second aspect
279279
is the choice of the letter, word, or words that make up a name. This
280-
is much more a matter of judgment, though there are guiding principles
280+
is much more a matter of judgement, though there are guiding principles
281281
that greatly help with clarity.</p>
282282
<div class="section" id="pep-8-name-conventions">
283283
<h3><span class="section-number">4.4.1. </span>PEP 8 name conventions<a class="headerlink" href="#pep-8-name-conventions" title="Permalink to this headline"></a></h3>

4_abstract_data_types.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ <h3><span class="section-number">5.3.1. </span>Amortised complexity and worst ca
513513
only occurs when the list has to be extended. How often is that?
514514
Suppose the list has just been reallocated (at a cost of
515515
<span class="math notranslate nohighlight">\(O(n)\)</span>). The new memory allocation is <span class="math notranslate nohighlight">\(kn\)</span> large, but we’ve
516-
aready used <span class="math notranslate nohighlight">\(n\)</span> locations so we get <span class="math notranslate nohighlight">\((k-1)n\)</span> more cheap
516+
already used <span class="math notranslate nohighlight">\(n\)</span> locations so we get <span class="math notranslate nohighlight">\((k-1)n\)</span> more cheap
517517
<span class="math notranslate nohighlight">\(O(1)\)</span> append operations before we have to reallocate
518518
again. <span class="math notranslate nohighlight">\((k-1)n = O(n)\)</span> so this means that adding <span class="math notranslate nohighlight">\(O(n)\)</span>
519519
items to the list costs:</p>

5_exceptions.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ <h3><span class="section-number">6.3.2. </span>Interpreting tracebacks<a class="
308308
<p>This shows information about a <a class="reference internal" href="#term-call-stack"><span class="xref std std-term">call stack</span></a> comprising three
309309
<a class="reference internal" href="#term-stack-frame"><span class="xref std std-term">stack frames</span></a>. Look first at the bottom-most
310310
frame, which corresponds to the function in which the exception
311-
occured. The traceback for this frame starts:</p>
311+
occurred. The traceback for this frame starts:</p>
312312
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="o">~/</span><span class="n">docs</span><span class="o">/</span><span class="nb">object</span><span class="o">-</span><span class="n">oriented</span><span class="o">-</span><span class="n">programming</span><span class="o">/</span><span class="n">src</span><span class="o">/</span><span class="n">polynomial</span><span class="o">.</span><span class="n">py</span> <span class="ow">in</span> <span class="fm">__add__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span>
313313
</pre></div>
314314
</div>
@@ -363,7 +363,7 @@ <h3><span class="section-number">6.3.2. </span>Interpreting tracebacks<a class="
363363
<a class="reference internal" href="#typesafe-fib"><span class="std std-numref">Listing 6.1</span></a>, we inform the user that we were expecting an
364364
integer rather than the type actually provided.</p>
365365
<div class="literal-block-wrapper docutils container" id="id5">
366-
<span id="typesafe-fib"></span><div class="code-block-caption"><span class="caption-number">Listing 6.1 </span><span class="caption-text">A version of the Fibbonacci function which raises an
366+
<span id="typesafe-fib"></span><div class="code-block-caption"><span class="caption-number">Listing 6.1 </span><span class="caption-text">A version of the Fibonacci function which raises an
367367
exception if a non-integer type is passed as the
368368
argument.</span><a class="headerlink" href="#id5" title="Permalink to this code"></a></div>
369369
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">numbers</span> <span class="kn">import</span> <span class="n">Integral</span>
@@ -406,8 +406,8 @@ <h3><span class="section-number">6.3.2. </span>Interpreting tracebacks<a class="
406406
between this and the previous errors we have seen is that the bottom
407407
<a class="reference internal" href="#term-stack-frame"><span class="xref std std-term">stack frame</span></a> explicitly shows the exception being raised, while
408408
previously the stack showed a piece of code where an error had
409-
occured. This minor difference has to do with whether the particular
410-
piece of code where the exception occured is written in Python, or is
409+
occurred. This minor difference has to do with whether the particular
410+
piece of code where the exception occurred is written in Python, or is
411411
written in a language such as C and called from Python. This
412412
distinction is of negligible importance for our current purposes.</p>
413413
<div class="admonition note">
@@ -530,7 +530,7 @@ <h3><span class="section-number">6.5.3. </span>Exception handling and the call s
530530
point which is ultimately inside several <a class="reference external" href="https://docs.python.org/3/reference/compound_stmts.html#try" title="(in Python v3.9)"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">try</span></code></a> blocks.</p>
531531
<p>The <a class="reference internal" href="1_programs_in_files.html#term-Python-interpreter"><span class="xref std std-term">Python interpreter</span></a> deals with this situation by starting
532532
from the current <a class="reference internal" href="#term-stack-frame"><span class="xref std std-term">stack frame</span></a> and working upwards, a process
533-
known as <em>unwinding the stack</em>. In pseudocode, the alogrithm is:</p>
533+
known as <em>unwinding the stack</em>. In pseudocode, the algorithm is:</p>
534534
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">while</span> <span class="n">call</span> <span class="n">stack</span> <span class="ow">not</span> <span class="n">empty</span><span class="p">:</span>
535535
<span class="k">if</span> <span class="n">current</span> <span class="n">execution</span> <span class="n">point</span> <span class="ow">is</span> <span class="ow">in</span> <span class="n">a</span> <span class="k">try</span> <span class="n">block</span> \
536536
<span class="k">with</span> <span class="n">an</span> <span class="k">except</span> <span class="n">matching</span> <span class="n">the</span> <span class="n">current</span> <span class="n">exception</span><span class="p">:</span>
@@ -551,9 +551,9 @@ <h2><span class="section-number">6.6. </span>Exceptions are not always errors<a
551551
concepts. While user errors and bugs in programs typically result in
552552
an exception being raised, it is not the case that all exceptions
553553
result from errors. The name “exception” means what it says, it is an
554-
event whose occurance requires an exception to the normal sequence of
554+
event whose occurrence requires an exception to the normal sequence of
555555
execution.</p>
556-
<p>The <a class="reference external" href="https://docs.python.org/3/library/exceptions.html#StopIteration" title="(in Python v3.9)"><code class="xref py py-class docutils literal notranslate"><span class="pre">StopIteration</span></code></a> exception which we encoutered in
556+
<p>The <a class="reference external" href="https://docs.python.org/3/library/exceptions.html#StopIteration" title="(in Python v3.9)"><code class="xref py py-class docutils literal notranslate"><span class="pre">StopIteration</span></code></a> exception which we encountered in
557557
<a class="reference internal" href="4_abstract_data_types.html#iterator-protocol"><span class="std std-numref">Section 5.5</span></a> is a good example of an <a class="reference internal" href="#term-exception"><span class="xref std std-term">exception</span></a>
558558
which does not indicate an error. The end of the set of things to be
559559
iterated over does not indicate that something has gone wrong, but it
@@ -575,12 +575,12 @@ <h2><span class="section-number">6.7. </span>Glossary<a class="headerlink" href=
575575
exception is <a class="reference internal" href="#raising-exceptions"><span class="std std-ref">raised</span></a> the
576576
<a class="reference internal" href="1_programs_in_files.html#term-Python-interpreter"><span class="xref std std-term">Python interpreter</span></a> doesn’t continue to execute the
577577
following line of code. Instead, the exception is either
578-
<a class="reference internal" href="#handling-exceptions"><span class="std std-ref">handled</span></a> or execution stips and a
578+
<a class="reference internal" href="#handling-exceptions"><span class="std std-ref">handled</span></a> or execution stops and a
579579
<a class="reference internal" href="#term-traceback"><span class="xref std std-term">traceback</span></a> is printed.</p>
580580
</dd>
581581
<dt id="term-stack-frame">stack frame</dt><dd><p>An object encapsulating the set of variables which define the
582582
execution of a Python script or function. This information
583-
includes the code being executed, all the local and gobal
583+
includes the code being executed, all the local and global
584584
names which are visible, the last instruction that was
585585
executed, and a reference to the stack frame which called this
586586
function.</p>

0 commit comments

Comments
 (0)