diff --git a/about.html b/about.html index e423ada..7d3ec25 100644 --- a/about.html +++ b/about.html @@ -11,7 +11,7 @@ h1:before{content:""} -
+The content of Dive Into Python 3 is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. diff --git a/case-study-porting-chardet-to-python-3.html b/case-study-porting-chardet-to-python-3.html index ca91a1f..3b6a50a 100644 --- a/case-study-porting-chardet-to-python-3.html +++ b/case-study-porting-chardet-to-python-3.html @@ -12,7 +12,7 @@ body{counter-reset:h1 20}
+chardet to Python 3diff --git a/dip3.css b/dip3.css index 64d0177..c5dfd70 100644 --- a/dip3.css +++ b/dip3.css @@ -1,61 +1,62 @@ /* typography */ -body,.widgets a{font:normal medium 'Gill Sans','Gill Sans MT',Corbel,Helvetica,Jara,'Nimbus Sans L',sans-serif;line-height:1.75;word-spacing:0.1em} -pre,kbd,code,samp{font:normal medium Consolas,'Andale Mono',Monaco,'Liberation Mono','Bitstream Vera Sans Mono','DejaVu Sans Mono',monospace;font-size:medium;line-height:1.75;word-spacing:0} -span,tr + tr th:first-child{font:normal medium 'Arial Unicode MS',FreeSerif,OpenSymbol,'DejaVu Sans',sans-serif} -pre span{font:normal medium 'Arial Unicode MS','DejaVu Sans',FreeSerif,OpenSymbol,sans-serif} +body,.widgets a{font:medium 'Gill Sans','Gill Sans MT',Corbel,Helvetica,Jara,'Nimbus Sans L',sans-serif;line-height:1.75;word-spacing:0.1em} +pre,kbd,code,samp{font-family:Consolas,'Andale Mono',Monaco,'Liberation Mono','Bitstream Vera Sans Mono','DejaVu Sans Mono',monospace;font-size:medium;line-height:1.75;word-spacing:0} +span,tr + tr th:first-child{font:medium 'Arial Unicode MS',FreeSerif,OpenSymbol,'DejaVu Sans',sans-serif} +pre span{font-family:'Arial Unicode MS','DejaVu Sans',FreeSerif,OpenSymbol,sans-serif} .baa{font:oblique large Constantia,Baskerville,Palatino,'Palatino Linotype','URW Palladio L',serif} -abbr{font-variant:small-caps;letter-spacing:0.1em;text-transform:lowercase} +abbr{font-variant:small-caps;text-transform:lowercase;letter-spacing:0.1em} .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{font-size:large} .note{margin-left:4.94em} .note span{display:block;float:left;font-size:xx-large;line-height:0.875;margin:0 0.22em 0 -1.22em} +.c,pre,.widgets,.widgets a,.download,ins,del,mark{line-height:2.154} +.fancy:first-letter{float:left;color:#ddd;padding:0.11em 4px 0 0;font:normal 4em/0.68 serif} +h1,h2,h3,p,ul,ol{margin:1.75em 0;font-size:medium} /* basics */ html{background:#fff;color:#000} -body{margin:28px} -#search div{float:right} -li ol{margin:0} -.c{text-align:center;font-size:small;line-height:2.154;margin:2.154em 0} +body{margin:1.75em 28px} +form div{float:right} +.c{text-align:center;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} +a:link,.widgets a{color:#26c} +a:visited{color:#93c} .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 solid gainsboro} +pre{white-space:pre-wrap;padding-left:2.154em;border-left:1px solid #ddd} .widgets{float:left} -.widgets,.widgets a,.download{font-size:small;line-height:2.154} -.block,ol,p,blockquote{clear:left} -pre a,.widgets a{padding:0.4375em 0;border:0} +.c,.widgets,.widgets a,.download{font-size:small} +.block,ol,p,blockquote,h1,h2,h3{clear:left} +pre a,.widgets a{padding:0.4375em 0} .widgets a{text-decoration:underline} -pre a:hover{border:0} kbd,mark{font-weight:bold} .prompt{color:#667} -ins,del,mark{text-decoration:none;font-style:normal;display:inline-block;width:100%;line-height:2.154} -del{background:salmon} -ins{background:palegreen} -mark{background:#ffff80} +ins,del,mark{text-decoration:none;font-style:normal;display:inline-block;width:100%} +del{background:#f87} +ins{background:#9f9} +mark{background:#ff8} /* tables */ table{width:100%;border-collapse:collapse} -th,td{width:45%;margin:0;padding:0 0.5em;border:1px solid #bbb} +th,td{width:45%;padding:0 0.5em;border:1px solid #bbb} th{text-align:left;vertical-align:baseline} td{vertical-align:top} th:first-child{width:10%;text-align:center} .simple th{font-family:inherit !important} -.hover{background:#eee;color:inherit;cursor:default} -td pre{margin:0;padding:0;border:0;background:inherit} +.hover{background:#eee;cursor:default} + +/* overrides */ +th,td,td pre,li ol{margin:0} +td pre{padding:0} +pre a,.widgets a,pre a:hover,td pre{border:0} /* headers */ -h1,h2,h3,p,ul,ol{margin:1.75em 0;font-size:medium} -h1,#noscript{background:papayawhip;width:100%} -h1,h2,h3{clear:both} -body{counter-reset:h1} +h1,#noscript{background:PapayaWhip;width:100%} h1:before{content:"Chapter " counter(h1) ". "} h1{counter-reset:h2} h2:before{counter-increment:h2;content:counter(h1) "." counter(h2) ". "} diff --git a/index.html b/index.html index 46ff1e2..f5ca63c 100644 --- a/index.html +++ b/index.html @@ -14,7 +14,7 @@ li:last-child:before{content:"A. \00a0 \00a0"} li.todo{background:white;color:gainsboro} - +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.
You can see the full table of contents (not finalized), or read what I’ve written so far:
@@ -41,7 +41,7 @@ li.todo{background:white;color:gainsboro}
-- Case study: porting
chardetto Python 3- Porting code to Python 3 with
2to3There is a changelog, a feed, and discussion on Reddit. During development, you can download the book by cloning the Mercurial repository: +
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/ diveintopython3The 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. diff --git a/native-datatypes.html b/native-datatypes.html index 76f3950..690a1bd 100644 --- a/native-datatypes.html +++ b/native-datatypes.html @@ -12,7 +12,7 @@ body{counter-reset:h1 2}Native datatypes
@@ -170,7 +170,7 @@ body{counter-reset:h1 2} >>> x * 2 ③ Fraction(2, 3) >>> fractions.Fraction(6, 4) ④ -Fraction(3, 2) +Fraction(3, 2)
- To start using fractions, import the
fractionsmodule.- To define a fraction, create a
Fractionobject and pass in the numerator and denominator. @@ -346,7 +346,7 @@ ValueError: list.index(x): x not in listLists in a boolean context
You can also use a list in a boolean context, such as an
ifstatement.->>> def is_it_true(anything): ① +>>> def is_it_true(anything): ... if anything: ... print("yes, it's true") ... else: @@ -439,15 +439,15 @@ KeyError: 'db.diveintopython3.org'Dictionaries in a boolean context
You can also use a list in a boolean context, such as an
ifstatement.->>> def is_it_true(anything): ① +>>> def is_it_true(anything): ... if anything: ... print("yes, it's true") ... else: ... print("no, it's false") ... ->>> is_it_true({}) ② +>>> is_it_true({}) ① no, it's false ->>> is_it_true({'a': 1}) ③ +>>> is_it_true({'a': 1}) ② yes, it's true
- In a boolean context, an empty dictionary is false. @@ -477,15 +477,15 @@ KeyError: 'db.diveintopython3.org'
Nonein a boolean contextIn a boolean context,
Noneis false andnot Noneis true.->>> def is_it_true(anything): +>>> def is_it_true(anything): ... if anything: ... print("yes, it's true") ... else: ... print("no, it's false") ... ->>> is_it_true(None) +>>> is_it_true(None) no, it's false ->>> is_it_true(not None) +>>> is_it_true(not None) yes, it's trueFurther reading
diff --git a/porting-code-to-python-3-with-2to3.html b/porting-code-to-python-3-with-2to3.html index 8f65dfb..ebbf058 100644 --- a/porting-code-to-python-3-with-2to3.html +++ b/porting-code-to-python-3-with-2to3.html @@ -14,7 +14,7 @@ h3:before{counter-increment:h3;content:"A." counter(h2) "." counter(h3) ". "}
+Porting code to Python 3 with
2to3diff --git a/regular-expressions.html b/regular-expressions.html index b0de674..28b4b4d 100644 --- a/regular-expressions.html +++ b/regular-expressions.html @@ -12,7 +12,7 @@ body{counter-reset:h1 4} +Regular expressions
diff --git a/table-of-contents.html b/table-of-contents.html index f923049..bff1787 100644 --- a/table-of-contents.html +++ b/table-of-contents.html @@ -15,7 +15,7 @@ ul{list-style:none;margin:0;padding:0} ul li ol{margin:0;padding:0 0 0 2.5em} - +Table of contents
diff --git a/unit-testing.html b/unit-testing.html index 8d31cf9..bf3a8da 100644 --- a/unit-testing.html +++ b/unit-testing.html @@ -12,7 +12,7 @@ body{counter-reset:h1 7}
+Unit testing
diff --git a/your-first-python-program.html b/your-first-python-program.html index 5757211..88e927c 100644 --- a/your-first-python-program.html +++ b/your-first-python-program.html @@ -12,7 +12,7 @@ body{counter-reset:h1 1} +Your first Python program
@@ -42,8 +42,8 @@ body{counter-reset:h1 1}Diving in
Books about programming usually start with a bunch of boring chapters about fundamentals and eventually 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.
[The code examples will be easier to follow if you enable Javascript, but whatever.] -
SUFFIXES = {1000: ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 1024: ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']}