mirror of
https://github.com/kennethreitz/dive-into-python3.git
synced 2026-06-05 23:10:17 +00:00
build fiddling
This commit is contained in:
@@ -209,7 +209,7 @@ Cache-Control: max-age=31536000, public</samp></pre>
|
||||
|
||||
<h2 id=whats-on-the-wire>What’s On The Wire?</h2>
|
||||
|
||||
<p>To see why this is inefficient and rude, let’s turn on the debugging features of Python’s <abbr>HTTP</abbr> library and see what’s being sent “on the wire.”
|
||||
<p>To see why this is inefficient and rude, let’s turn on the debugging features of Python’s <abbr>HTTP</abbr> library and see what’s being sent “on the wire” (<i>i.e.</i> over the network).
|
||||
|
||||
<pre class=screen>
|
||||
<samp class=p>>>> </samp><kbd class=pp>from http.client import HTTPConnection</kbd>
|
||||
|
||||
@@ -1,4 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () {
|
||||
echo "$1" >/dev/stderr
|
||||
exit 1
|
||||
}
|
||||
|
||||
hg status|grep "^\?" && die "Stray files found."
|
||||
echo "running unit tests"
|
||||
cd examples/
|
||||
python3 regression.py
|
||||
cd ..
|
||||
ssh diveintomark.org "hg -R /home/mark/db/diveintopython3/ serve --stdio" &
|
||||
hg push ssh://mark@diveintomark.org//home/mark/db/diveintopython3/
|
||||
|
||||
@@ -134,7 +134,7 @@ SyntaxError: non-keyword arg after keyword arg</samp></pre>
|
||||
<p class=a>⁂
|
||||
|
||||
<h2 id=readability>Writing Readable Code</h2>
|
||||
<p>I won’t bore you with a long finger-wagging speech about the importance of documenting your code. Just know that code is written once but read many times, and the most important audience for your code is yourself, six months after writing it (i.e. after you’ve forgotten everything but need to fix something). Python makes it easy to write readable code, so take advantage of it. You’ll thank me in six months.
|
||||
<p>I won’t bore you with a long finger-wagging speech about the importance of documenting your code. Just know that code is written once but read many times, and the most important audience for your code is yourself, six months after writing it (<i>i.e.</i> after you’ve forgotten everything but need to fix something). Python makes it easy to write readable code, so take advantage of it. You’ll thank me in six months.
|
||||
<h3 id=docstrings>Documentation Strings</h3>
|
||||
<p>You can document a Python function by giving it a documentation string (<code>docstring</code> for short). In this program, the <code>approximate_size()</code> function has a <code>docstring</code>:
|
||||
<pre><code class=pp>def approximate_size(size, a_kilobyte_is_1024_bytes=True):
|
||||
|
||||
Reference in New Issue
Block a user