mirror of
https://github.com/kennethreitz/dive-into-python3.git
synced 2026-06-05 23:10:17 +00:00
CHANGED LICENSE TO CC-BY-SA-3.0 at publisher's request, also some line-height css fiddling
This commit is contained in:
@@ -717,7 +717,7 @@ for line in open(f, 'rb'):
|
||||
elif (self._mInputState == ePureAscii) and self._escDetector.search(self._mLastChar + aBuf):
|
||||
TypeError: Can't convert 'bytes' object to str implicitly</samp></pre>
|
||||
<p id="skipcantconvertbytesobject">...
|
||||
<p class="c">© 2001-4, 2009 <span>ℳ</span>ark Pilgrim, <a rel="license" href="http://creativecommons.org/licenses/by/3.0/">CC-BY-3.0</a>
|
||||
<p class="c">© 2001-4, 2009 <span>ℳ</span>ark Pilgrim, <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA-3.0</a>
|
||||
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
|
||||
<script type="text/javascript" src="dip3.js"></script>
|
||||
</body>
|
||||
|
||||
@@ -1,47 +1,63 @@
|
||||
/* fonts and margins */
|
||||
html{background:#fff;color:#000}
|
||||
body{margin:28px}
|
||||
body,.widgets a{font:normal medium 'Gill Sans','Gill Sans MT','Ikarius ADF',Candara,Jara,sans-serif;line-height:1.75;word-spacing:0.1em}
|
||||
body,.widgets a{font:normal medium 'Gill Sans','Gill Sans MT',Candara,Jara,sans-serif;line-height:1.75;word-spacing:0.1em}
|
||||
pre,kbd,code,samp{font-family:Consolas,Inconsolata,Monaco,monospace;font-size:medium;word-spacing:0}
|
||||
abbr{font:small-caps large inherit;letter-spacing:0.1em;text-transform:lowercase}
|
||||
|
||||
/* header */
|
||||
#search div{float:right}
|
||||
|
||||
/* table of contents */
|
||||
li ol{margin:0}
|
||||
|
||||
/* footer */
|
||||
.c{text-align:center;font-size:small;line-height:2.154;margin:2.154em 0}
|
||||
|
||||
/* links */
|
||||
a{background:transparent;text-decoration:none;border-bottom:1px dotted}
|
||||
a:hover{border-bottom:1px solid}
|
||||
a:link,.widgets a{color:#1b67c9}
|
||||
a:visited{color:darkorchid}
|
||||
.widgets a{text-decoration:underline;border:0}
|
||||
.widgets,.widgets a,.download,.c{font-size:small}
|
||||
blockquote .widgets{float:left}
|
||||
blockquote .block{clear:left}
|
||||
h1 a,h2 a,h3 a,#nav a{color:inherit !important}
|
||||
abbr,acronym{letter-spacing:0.1em;text-transform:lowercase;font-variant:small-caps}
|
||||
h1,h2,h3,p,ul,ol{margin:1.75em 0;font-size:medium}
|
||||
h1{background:papayawhip;width:100%}
|
||||
h2,h3{clear:both}
|
||||
form div{float:right}
|
||||
pre{white-space:pre-wrap;padding-left:2.154em;line-height:1.75;border-left:1px dotted}
|
||||
pre,kbd,code,samp{font-family:Consolas,Inconsolata,Monaco,monospace;font-size:medium;word-spacing:0}
|
||||
.skip a,.skip a:hover,.skip a:visited{position:absolute;left:0px;top:-500px;width:1px;height:1px;overflow:hidden}
|
||||
.skip a:active,.skip a:focus{position:static;width:auto;height:auto}
|
||||
|
||||
/* code blocks */
|
||||
pre{white-space:pre-wrap;padding-left:2.154em;line-height:2.154;border-left:1px dotted}
|
||||
.widgets{float:left}
|
||||
.widgets,.widgets a,.download{font-size:small;line-height:2.154}
|
||||
.block{clear:left}
|
||||
pre a,.widgets a{padding:0.4375em 0;border:0}
|
||||
.widgets a{text-decoration:underline}
|
||||
pre a:hover{border:0}
|
||||
kbd{font-weight:bold}
|
||||
.prompt{color:#667}
|
||||
td pre{margin:0;padding:0;border:0}
|
||||
li ol{margin:0}
|
||||
.c{text-align:center}
|
||||
p.fancy:first-letter{float:left;background:transparent;color:gainsboro;padding:0.11em 4px 0 0;font:normal 4em/0.68 serif}
|
||||
blockquote.q{margin:auto;text-align:right;font-style:oblique}
|
||||
.skip a,.skip a:hover,.skip a:visited{position:absolute;left:0px;top:-500px;width:1px;height:1px;overflow:hidden}
|
||||
.skip a:active,.skip a:focus{position:static;width:auto;height:auto}
|
||||
|
||||
/* headers */
|
||||
h1,h2,h3,p,ul,ol{margin:1.75em 0;font-size:medium}
|
||||
h1{background:papayawhip;width:100%}
|
||||
h1,h2,h3{clear:both}
|
||||
|
||||
/* tables */
|
||||
table{width:100%;border-collapse:collapse}
|
||||
th{text-align:left;padding:0 0.5em;vertical-align:baseline;border:1px dotted}
|
||||
th,td{width:45%;vertical-align:top}
|
||||
td{border:1px dotted;padding:0 0.5em}
|
||||
th,td{width:45%;margin:0;padding:0 0.5em}
|
||||
th{text-align:left;vertical-align:baseline}
|
||||
td{vertical-align:top}
|
||||
th:first-child{width:10%;text-align:center}
|
||||
span,tr + tr th:first-child{font-family:'Arial Unicode MS',sans-serif;font-style:normal}
|
||||
.simple th{font-family:inherit !important}
|
||||
.hover{background:#eee;color:inherit;cursor:default}
|
||||
td pre{margin:0;padding:0;border:0}
|
||||
|
||||
/* typographical flourishes */
|
||||
.q{margin:auto;text-align:right;font-style:oblique}
|
||||
.fancy:first-letter{float:left;background:transparent;color:gainsboro;padding:0.11em 4px 0 0;font:normal 4em/0.68 serif}
|
||||
.q span,pre span,tr + tr th:first-child{font:normal medium 'Arial Unicode MS',sans-serif}
|
||||
.q span{font-size:large}
|
||||
.note{margin-left:4.94em}
|
||||
.note span{display:block;float:left;font-size:xx-large;line-height:0.875em;margin:0 0.22em 0 -1.22em}
|
||||
table.simple th{font-family:inherit !important}
|
||||
.fr{width:100%;border:1px dotted;margin-top:3.5em}
|
||||
.fr h4{margin-top:-1.2em;margin-left:-1em;width:8.5em;border:1px dotted;padding: 3px 3px 3px 13px;background:#fff;color:inherit;position:relative}
|
||||
.hover{background:#eee;color:inherit;cursor:default}
|
||||
i.baa{font-family:Baskerville,Constantia,Palatino,'Palatino Linotype','URW Palladio L','URW Bookman L',serif}
|
||||
.baa{font:oblique large Baskerville,Constantia,Palatino,'Palatino Linotype','URW Palladio L',serif}
|
||||
|
||||
/* section counters */
|
||||
body{counter-reset:h1}
|
||||
h1:before{content:"Chapter " counter(h1) ". "}
|
||||
h1{counter-reset:h2}
|
||||
|
||||
@@ -55,6 +55,7 @@ $(document).ready(function() {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}); /* document.ready */
|
||||
}); /* google.setOnLoadCallback */
|
||||
|
||||
|
||||
+3
-3
@@ -13,7 +13,7 @@ ul{list-style:none}
|
||||
</head>
|
||||
<body>
|
||||
<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"><input name="q" size="31"> <input type="submit" name="sa" value="Search"></div></form>
|
||||
<p class="first"><cite>Dive Into Python 3</cite> will cover Python 3 and its differences from Python 2. Compared to the original <cite><a href="http://diveintopython.org/">Dive Into Python</a></cite>, it will be about 50% revised and 50% new material. I will publish drafts online as I go. The final version will be published on paper by Apress. The book will remain online under the <a rel="license" href="http://creativecommons.org/licenses/by/3.0/">CC-BY-3.0</a> license.
|
||||
<p class="first"><cite>Dive Into Python 3</cite> will cover Python 3 and its differences from Python 2. Compared to the original <cite><a href="http://diveintopython.org/">Dive Into Python</a></cite>, it will be about 50% revised and 50% new material. I will publish drafts online as I go. The final version will be published on paper by Apress. The book will remain online under the <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA-3.0</a> license.
|
||||
<p>Here’s what I’ve written so far:</p>
|
||||
<ul>
|
||||
<li><a href="table-of-contents.html">Table of contents</a> (<strong>not finalized</strong>)
|
||||
@@ -24,9 +24,9 @@ ul{list-style:none}
|
||||
</ul>
|
||||
<p>There is a <a href="http://hg.diveintopython3.org/">changelog</a>, a <a rel="alternate" type="application/atom+xml" href="http://hg.diveintopython3.org/atom-log">feed</a>, and <a href="http://www.reddit.com/search?q=%22Dive+Into+Python+3%22&sort=new">discussion on Reddit</a>. During development, you can download the book by cloning the Mercurial repository:
|
||||
<pre><samp class="prompt">you@localhost:~$ </samp><kbd>hg clone http://hg.diveintopython3.org/ diveintopython3</kbd></pre>
|
||||
<p>The final version will be downloadable as HTML and PDF.
|
||||
<p>The final version will be downloadable as <abbr>HTML</abbr> and <abbr>PDF</abbr>.
|
||||
<p class="c">This site is optimized for Lynx just because fuck you.<br>I’m told it also looks good in graphical browsers.
|
||||
<p class="c">© 2001-4, 2009 <span>ℳ</span>ark Pilgrim, <a rel="license" href="http://creativecommons.org/licenses/by/3.0/">CC-BY-3.0</a>
|
||||
<p class="c">© 2001-4, 2009 <span>ℳ</span>ark Pilgrim, <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA-3.0</a>
|
||||
<!--
|
||||
As I write this, the year is 2009, and the internet is STILL a battleground of so-called "intellectual property" disputes. Some people would have you believe that without proper financial incentives, music, literature, and software would disappear. After all, who would make music if they can't make money on it? Who would write? Who would program?
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ body{counter-reset:h1 2}
|
||||
-->
|
||||
<li><a href="#dictionaries">Dictionaries</a>
|
||||
<li><a href="#none"><code>None</code></a>
|
||||
<li><a href="#furtherreading">Further reading</a>
|
||||
</ol>
|
||||
<h2 id="divingin">Diving in</h2>
|
||||
<p class="fancy">A short digression is in order. Put aside <a href="your-first-python-program.html">your first Python program</a> for just a minute, and let's talk about datatypes. <a href="your-first-python-program.html#datatypes">Every variable has a datatype</a>, even though you don't declare it explicitly. Based on each variable's original assignment, Python figures out what type it is and keeps tracks of that internally.
|
||||
@@ -247,8 +248,7 @@ KeyError: 'db.diveintopython3.org'</samp></pre>
|
||||
<samp class="prompt">>>> </samp><kbd>x == y</kbd>
|
||||
<samp>True</samp>
|
||||
</pre>
|
||||
<div class="fr">
|
||||
<h4>Further reading (FIXME)</h4>
|
||||
<h3 id="furtherreading">Further reading</h3>
|
||||
<ul>
|
||||
<li>fractions
|
||||
<li>math module
|
||||
@@ -257,8 +257,7 @@ KeyError: 'db.diveintopython3.org'</samp></pre>
|
||||
<li>links to appendix
|
||||
<li>...etc...
|
||||
</ul>
|
||||
</div>
|
||||
<p class="c">© 2001-4, 2009 <span>ℳ</span>ark Pilgrim, <a rel="license" href="http://creativecommons.org/licenses/by/3.0/">CC-BY-3.0</a>
|
||||
<p class="c">© 2001-4, 2009 <span>ℳ</span>ark Pilgrim, <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA-3.0</a>
|
||||
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
|
||||
<script type="text/javascript" src="dip3.js"></script>
|
||||
</body>
|
||||
|
||||
@@ -1271,7 +1271,7 @@ do_stuff(a_list)</code></pre></td></tr>
|
||||
</table>
|
||||
<p id="skipcompareidioms">
|
||||
<p>FIXME: once the rest of the book is written, this appendix should contain copious links back to any chapter or section that touches on these features.
|
||||
<p class="c">© 2001-4, 2009 <span>ℳ</span>ark Pilgrim, <a rel="license" href="http://creativecommons.org/licenses/by/3.0/">CC-BY-3.0</a>
|
||||
<p class="c">© 2001-4, 2009 <span>ℳ</span>ark Pilgrim, <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA-3.0</a>
|
||||
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
|
||||
<script type="text/javascript" src="dip3.js"></script>
|
||||
</body>
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
rm -rf build
|
||||
mkdir build
|
||||
cp *.html *.py *.txt .htaccess build/
|
||||
revision=`hg log|grep changeset|cut -d":" -f3|head -1`
|
||||
java -jar yuicompressor-2.4.2.jar dip3.js > build/dip3.$revision.min.js
|
||||
java -jar yuicompressor-2.4.2.jar dip3.css > build/dip3.$revision.min.css
|
||||
sed -i -e "s|dip3\.js|http://wearehugh.com/dip3/dip3.${revision}.min.js|g" build/*.html
|
||||
sed -i -e "s|dip3\.css|http://wearehugh.com/dip3/dip3.${revision}.min.css|g" build/*.html
|
||||
chmod 644 build/*.html build/*.css build/*.js build/*.py build/*.txt build/.htaccess
|
||||
rsync -essh -avzP --delete --delete-after build/*.min.css build/*.min.js diveintomark.org:~/web/wearehugh.com/dip3/
|
||||
rsync -essh -avzP build/*.html build/*.py build/*.txt build/.htaccess diveintomark.org:~/web/diveintopython3.org/
|
||||
+17
-15
@@ -44,26 +44,28 @@ ul li ol{margin:0;padding:0 0 0 2.5em}
|
||||
</ol>
|
||||
<li><a href="your-first-python-program.html#indentingcode">Indenting code</a>
|
||||
<li><a href="your-first-python-program.html#runningscripts">Running scripts</a>
|
||||
<li><a href="your-first-python-program.html#furtherreading">Further reading</a>
|
||||
</ol>
|
||||
<li><a href="native-datatypes.html">Native Python datatypes</a>
|
||||
<ol>
|
||||
<li><a href="native-datatypes.html#divingin">Diving in</a>
|
||||
<li><a href="native-datatypes.html#booleans">Booleans</a>
|
||||
<li><a href="native-datatypes.html#numbers">Numbers</a>
|
||||
<li><a href="native-datatypes.html#divingin">Diving in</a>
|
||||
<li><a href="native-datatypes.html#booleans">Booleans</a>
|
||||
<li><a href="native-datatypes.html#numbers">Numbers</a>
|
||||
<!--
|
||||
<ol>
|
||||
<li><a href="native-datatypes.html#integers">Integers</a>
|
||||
<li><a href="native-datatypes.html#floats">Floating point numbers</a>
|
||||
<li><a href="native-datatypes.html#fractions">Fractions</a>
|
||||
<li><a href="native-datatypes.html#complexnumbers">Complex numbers</a>
|
||||
<li><a href="native-datatypes.html#numberoperations">Common operations on numbers</a>
|
||||
<li><a href="native-datatypes.html#math">The <code>math</code> module</a>
|
||||
<ol>
|
||||
<li><a href="native-datatypes.html#integers">Integers</a>
|
||||
<li><a href="native-datatypes.html#floats">Floating point numbers</a>
|
||||
<li><a href="native-datatypes.html#fractions">Fractions</a>
|
||||
<li><a href="native-datatypes.html#complexnumbers">Complex numbers</a>
|
||||
<li><a href="native-datatypes.html#numberoperations">Common operations on numbers</a>
|
||||
<li><a href="native-datatypes.html#math">The <code>math</code> module</a>
|
||||
</ol>
|
||||
-->
|
||||
<li><a href="native-datatypes.html#lists">Lists</a>
|
||||
<li><a href="native-datatypes.html#sets">Sets</a>
|
||||
<li><a href="native-datatypes.html#dictionaries">Dictionaries
|
||||
<li><a href="native-datatypes.html#none"><code>None</code></a>
|
||||
<li><a href="native-datatypes.html#lists">Lists</a>
|
||||
<li><a href="native-datatypes.html#sets">Sets</a>
|
||||
<li><a href="native-datatypes.html#dictionaries">Dictionaries
|
||||
<li><a href="native-datatypes.html#none"><code>None</code></a>
|
||||
<li><a href="native-datatypes.html#furtherreading">Further reading</a>
|
||||
</ol>
|
||||
<li>Strings
|
||||
<ol>
|
||||
@@ -365,6 +367,6 @@ ul li ol{margin:0;padding:0 0 0 2.5em}
|
||||
<li>Dictionary comprehensions
|
||||
<li>Views (several dictionary methods return them, they're dynamic, update when the dictionary changes, etc.)
|
||||
</ul>
|
||||
<p class="c">© 2001-4, 2009 <span>ℳ</span>ark Pilgrim, <a rel="license" href="http://creativecommons.org/licenses/by/3.0/">CC-BY-3.0</a>
|
||||
<p class="c">© 2001-4, 2009 <span>ℳ</span>ark Pilgrim, <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA-3.0</a>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -37,6 +37,7 @@ body{counter-reset:h1 1}
|
||||
</ol>
|
||||
<li><a href="#indentingcode">Indenting code</a>
|
||||
<li><a href="#runningscripts">Running scripts</a>
|
||||
<li><a href="#furtherreading">Further reading</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.
|
||||
@@ -228,16 +229,14 @@ if __name__ == "__main__":
|
||||
<pre class="screen"><samp class="prompt">c:\home\diveintopython3> </samp><kbd>c:\python30\python.exe humansize.py</kbd>
|
||||
<samp>1.0 TB
|
||||
931.3 GiB</samp></pre>
|
||||
<div class="fr">
|
||||
<h4>Further reading</h4>
|
||||
<h3 id="furtherreading">Further reading</h3>
|
||||
<ul>
|
||||
<li><a href="http://www.python.org/dev/peps/pep-0257/">PEP 257: Docstring Conventions</a> explains what distinguishes a good <code>docstring</code> from a great <code>docstring</code>.
|
||||
<li><a href="http://docs.python.org/3.0/tutorial/controlflow.html#documentation-strings">Python Tutorial: Documentation Strings</a> also touches on the subject.
|
||||
<li><a href="http://www.python.org/dev/peps/pep-0008/">PEP 8: Style Guide for Python Code</a> discusses good indentation style.
|
||||
<li><a href="http://docs.python.org/3.0/reference/"><cite>Python Reference Manual</cite></a> explains what it means to say that <a href="http://docs.python.org/3.0/reference/datamodel.html#objects-values-and-types">everything in Python is an object</a>, because some people are pedantic and like to discuss that sort of thing at great length.
|
||||
</ul>
|
||||
</div>
|
||||
<p class="c">© 2001-4, 2009 <span>ℳ</span>ark Pilgrim, <a rel="license" href="http://creativecommons.org/licenses/by/3.0/">CC-BY-3.0</a>
|
||||
<p class="c">© 2001-4, 2009 <span>ℳ</span>ark Pilgrim, <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA-3.0</a>
|
||||
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
|
||||
<script type="text/javascript" src="dip3.js"></script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user