search box and more skip links

This commit is contained in:
Mark Pilgrim
2009-02-04 01:22:01 -05:00
parent ae6b88465b
commit 8441b2f82c
6 changed files with 25 additions and 11 deletions
+7 -2
View File
@@ -10,6 +10,8 @@ body{counter-reset:h1 1}
</style>
</head>
<body>
<p class="skip"><a href="#divingin">skip to main content</a>
<form action="http://www.google.com/cse" id="search"><div><input type="hidden" name="cx" value="014021643941856155761:l5eihuescdw"><input type="hidden" name="ie" value="UTF-8">&nbsp;<input name="q" size="31">&nbsp;<input type="submit" name="sa" value="Search"></div><p>You are here: <a href="index.html">Dive Into Python 3</a> <span>&#8227;</span> <b>Chapter 2</b></form>
<h1>Your first Python program</h1>
<blockquote class="q">
<p><span>&#x275D;</span> Don&#8217;t bury your burden in saintly silence. You have a problem? Great. Rejoice, dive in, and investigate. <span>&#x275E;</span><br>&mdash; <cite>Ven. Henepola Gunararatana</cite>
@@ -17,7 +19,7 @@ body{counter-reset:h1 1}
<ol>
<li><a href="#divingin">Diving in</a>
<li><a href="#declaringfunctions">Declaring functions</a>
<li><a href="#documentingfunctions">Documenting functions</a>
<li><a href="#readability">Writing readable code</a>
</ol>
<h2 id="divingin">Diving in</h2>
<p class="fancy">You know how other books go on and on about programming fundamentals and finally work up to building something useful? Let's skip all that. Here is a complete, working Python program. It probably makes absolutely no sense to you. Don't worry about that, because you're going to dissect it line by line. But read through it first and see what, if anything, you can make of it.
@@ -92,7 +94,10 @@ if __name__ == "__main__":
<tr><th>Weakly typed</th><td>C, Objective-C</td><td>JavaScript, Perl 5, PHP</td></tr>
<tr><th>Strongly typed</th><td>Pascal, Java</td><td>Python, Ruby</td></tr>
</table>
<h2 id="documentingfunctions">Documenting functions</h2>
<h2 id="readability">Writing readable code</h2>
FIXME
<p>You can document a Python function by giving it a <code>docstring</code>. In this program, the <code>approximate_size</code> function has a <code>docstring</code>:
<pre><code>def approximate_size(size, a_kilobyte_is_1024_bytes=True):
"""Convert a file size to human-readable form.