From 3c39352a322db6c5197dd0d9ec7a741ebc6df71e Mon Sep 17 00:00:00 2001 From: Mark Pilgrim Date: Thu, 12 Feb 2009 02:16:49 -0500 Subject: [PATCH] CHANGED LICENSE TO CC-BY-SA-3.0 at publisher's request, also some line-height css fiddling --- case-study-porting-chardet-to-python-3.html | 2 +- dip3.css | 74 +++++++++++++-------- dip3.js | 1 + index.html | 6 +- native-datatypes.html | 7 +- porting-code-to-python-3-with-2to3.html | 2 +- publish | 13 ++++ table-of-contents.html | 32 ++++----- your-first-python-program.html | 7 +- 9 files changed, 87 insertions(+), 57 deletions(-) create mode 100644 publish diff --git a/case-study-porting-chardet-to-python-3.html b/case-study-porting-chardet-to-python-3.html index 4a84ccd..ce6fb63 100644 --- a/case-study-porting-chardet-to-python-3.html +++ b/case-study-porting-chardet-to-python-3.html @@ -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

... -

© 2001-4, 2009 ark Pilgrim, CC-BY-3.0 +

© 2001-4, 2009 ark Pilgrim, CC-BY-SA-3.0 diff --git a/dip3.css b/dip3.css index 62929d3..8a5f15c 100644 --- a/dip3.css +++ b/dip3.css @@ -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} diff --git a/dip3.js b/dip3.js index 6d0889f..2b79413 100644 --- a/dip3.js +++ b/dip3.js @@ -55,6 +55,7 @@ $(document).ready(function() { } }); }); + }); /* document.ready */ }); /* google.setOnLoadCallback */ diff --git a/index.html b/index.html index 981c9e9..72c4037 100644 --- a/index.html +++ b/index.html @@ -13,7 +13,7 @@ ul{list-style:none}

-

Dive Into Python 3 will cover Python 3 and its differences from Python 2. Compared to the original Dive Into Python, 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 CC-BY-3.0 license. +

Dive Into Python 3 will cover Python 3 and its differences from Python 2. Compared to the original Dive Into Python, 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 CC-BY-SA-3.0 license.

Here’s what I’ve written so far:

There is a changelog, a feed, and discussion on Reddit. During development, you can download the book by cloning the Mercurial repository:

you@localhost:~$ hg clone http://hg.diveintopython3.org/ diveintopython3
-

The final version will be downloadable as HTML and PDF. +

The final version will be downloadable as HTML and PDF.

This site is optimized for Lynx just because fuck you.
I’m told it also looks good in graphical browsers. -

© 2001-4, 2009 ark Pilgrim, CC-BY-3.0 +

© 2001-4, 2009 ark Pilgrim, CC-BY-SA-3.0

  • Dictionaries
  • None +
  • Further reading

    Diving in

    A short digression is in order. Put aside your first Python program for just a minute, and let's talk about datatypes. Every variable has a datatype, 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' >>> x == y True -

    -

    Further reading (FIXME)

    +

    Further reading

    • fractions
    • math module @@ -257,8 +257,7 @@ KeyError: 'db.diveintopython3.org'
    • links to appendix
    • ...etc...
    -
    -

    © 2001-4, 2009 ark Pilgrim, CC-BY-3.0 +

    © 2001-4, 2009 ark Pilgrim, CC-BY-SA-3.0 diff --git a/porting-code-to-python-3-with-2to3.html b/porting-code-to-python-3-with-2to3.html index f143df6..e13c429 100644 --- a/porting-code-to-python-3-with-2to3.html +++ b/porting-code-to-python-3-with-2to3.html @@ -1271,7 +1271,7 @@ do_stuff(a_list)

    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. -

    © 2001-4, 2009 ark Pilgrim, CC-BY-3.0 +

    © 2001-4, 2009 ark Pilgrim, CC-BY-SA-3.0 diff --git a/publish b/publish new file mode 100644 index 0000000..7ac7a20 --- /dev/null +++ b/publish @@ -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/ diff --git a/table-of-contents.html b/table-of-contents.html index 0a39f78..c32050b 100644 --- a/table-of-contents.html +++ b/table-of-contents.html @@ -44,26 +44,28 @@ ul li ol{margin:0;padding:0 0 0 2.5em}

  • Indenting code
  • Running scripts +
  • Further reading
  • Native Python datatypes
      -
    1. Diving in -
    2. Booleans -
    3. Numbers +
    4. Diving in +
    5. Booleans +
    6. Numbers -
    7. Lists -
    8. Sets -
    9. Dictionaries -
    10. None +
    11. Lists +
    12. Sets +
    13. Dictionaries +
    14. None +
    15. Further reading
  • Strings
      @@ -365,6 +367,6 @@ ul li ol{margin:0;padding:0 0 0 2.5em}
    1. Dictionary comprehensions
    2. Views (several dictionary methods return them, they're dynamic, update when the dictionary changes, etc.) -

      © 2001-4, 2009 ark Pilgrim, CC-BY-3.0 +

      © 2001-4, 2009 ark Pilgrim, CC-BY-SA-3.0 diff --git a/your-first-python-program.html b/your-first-python-program.html index a14102c..2f4205c 100644 --- a/your-first-python-program.html +++ b/your-first-python-program.html @@ -37,6 +37,7 @@ body{counter-reset:h1 1}

  • Indenting code
  • Running scripts +
  • Further reading

    Diving in

    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__":

    c:\home\diveintopython3> c:\python30\python.exe humansize.py
     1.0 TB
     931.3 GiB
    -
    -

    Further reading

    +

    Further reading

    -
    -

    © 2001-4, 2009 ark Pilgrim, CC-BY-3.0 +

    © 2001-4, 2009 ark Pilgrim, CC-BY-SA-3.0