generate in-page TOCs on demand

This commit is contained in:
Mark Pilgrim
2009-03-19 01:42:12 -04:00
parent cfeee5d73d
commit 3b9c6c67e9
8 changed files with 29 additions and 189 deletions
+1 -42
View File
@@ -13,48 +13,7 @@ body{counter-reset:h1 2}
<blockquote class=q>
<p><span>&#x275D;</span> Wonder is the foundation of all philosophy, research its progress, ignorance its end. <span>&#x275E;</span><br>&mdash; <cite>Michel de Montaigne</cite>
</blockquote>
<ol>
<li><a href=#divingin>Diving in</a>
<li><a href=#booleans>Booleans</a>
<li><a href=#numbers>Numbers</a>
<ol>
<li><a href=#number-coercion>Coercing integers to floats and vice-versa</a>
<li><a href=#common-numerical-operations>Common numerical operations</a>
<li><a href=#fractions>Fractions</a>
<li><a href=#trig>Trigonometry</a>
<li><a href=#numbers-in-a-boolean-context>Numbers in a boolean context</a>
</ol>
<li><a href=#lists>Lists</a>
<ol>
<li><a href=#creatinglists>Creating a list</a>
<li><a href=#slicinglists>Slicing a list</a>
<li><a href=#extendinglists>Adding items to a list</a>
<li><a href=#searchinglists>Searching for values in a list</a>
<li><a href=#lists-in-a-boolean-context>Lists in a boolean context</a>
</ol>
<!--
<li><a href=#sets>Sets</a>
<ol>
<li>Creating a new set
<li>Modifying a set
<li>Deleting items from a set
<li>Common operations on sets (union, intersection, and difference)
<li>Frozen sets
</ol>
-->
<li><a href=#dictionaries>Dictionaries</a>
<ol>
<li><a href=#creating-dictionaries>Creating a dictionary</a>
<li><a href=#modifying-dictionaries>Modifying a dictionary</a>
<li><a href=#mixed-value-dictionaries>Mixed-value dictionaries</a>
<li><a href=#dictionaries-in-a-boolean-context>Dictionaries in a boolean context</a>
</ol>
<li><a href=#none><code>None</code></a>
<ol>
<li><a href=#none-in-a-boolean-context><code>None</code> in a boolean context</a>
</ol>
<li><a href=#furtherreading>Further reading</a>
</ol>
<p id=toc>&nbsp;
<h2 id=divingin>Diving in</h2>
<p class=f>Cast aside <a href=your-first-python-program.html>your first Python program</a> for just a minute, and let's talk about datatypes. In Python, <a href=your-first-python-program.html#datatypes>every variable has a datatype</a>, but you don't need to declare it explicitly. Based on each variable's original assignment, Python figures out what type it is and keeps tracks of that internally.
<p>Python has many native datatypes. Here are the important ones: