mirror of
https://github.com/kennethreitz/dive-into-python3.git
synced 2026-06-05 23:10:17 +00:00
fixed URLs to python docs (WHICH CHANGED OUT FROM UNDER ME)
This commit is contained in:
@@ -1115,7 +1115,7 @@ tests\Big5\0804.blogspot.com.xml</samp>
|
||||
File "C:\home\chardet\chardet\latin1prober.py", line 126, in get_confidence
|
||||
total = reduce(operator.add, self._mFreqCounter)
|
||||
NameError: global name 'reduce' is not defined</samp></pre>
|
||||
<p>According to the official <a href=http://docs.python.org/dev/3.0/whatsnew/3.0.html#builtins>What's New In Python 3.0</a> guide, the <code>reduce()</code> function has been moved out of the global namespace and into the <code>functools</code> module. Quoting the guide: "Use <code>functools.reduce()</code> if you really need it; however, 99 percent of the time an explicit <code>for</code> loop is more readable." You can read more about the decision from Guido van Rossum's weblog: <a href="http://www.artima.com/weblogs/viewpost.jsp?thread=98196">The fate of reduce() in Python 3000</a>.
|
||||
<p>According to the official <a href=http://docs.python.org/3.0/whatsnew/3.0.html#builtins>What's New In Python 3.0</a> guide, the <code>reduce()</code> function has been moved out of the global namespace and into the <code>functools</code> module. Quoting the guide: "Use <code>functools.reduce()</code> if you really need it; however, 99 percent of the time an explicit <code>for</code> loop is more readable." You can read more about the decision from Guido van Rossum's weblog: <a href="http://www.artima.com/weblogs/viewpost.jsp?thread=98196">The fate of reduce() in Python 3000</a>.
|
||||
<pre><code>def get_confidence(self):
|
||||
if self.get_state() == constants.eNotMe:
|
||||
return 0.01
|
||||
|
||||
@@ -448,8 +448,8 @@ KeyError: 'db.diveintopython3.org'</samp></pre>
|
||||
<samp>yes, it's true</samp></pre>
|
||||
<h2 id=furtherreading>Further Reading</h2>
|
||||
<ul>
|
||||
<li><a href="http://docs.python.org/dev/3.0/library/fractions.html">The <code>fractions</code> module</a>
|
||||
<li><a href="http://docs.python.org/dev/3.0/library/math.html">The <code>math</code> module</a>
|
||||
<li><a href="http://docs.python.org/3.0/library/fractions.html">The <code>fractions</code> module</a>
|
||||
<li><a href="http://docs.python.org/3.0/library/math.html">The <code>math</code> module</a>
|
||||
<li><a href="http://www.python.org/dev/peps/pep-0237/"><abbr>PEP</abbr> 237: Unifying Long Integers and Integers</a>
|
||||
<li><a href="http://www.python.org/dev/peps/pep-0238/"><abbr>PEP</abbr> 238: Changing the Division Operator</a>
|
||||
</ul>
|
||||
|
||||
+6
-6
@@ -219,7 +219,7 @@ def approximate_size(size, a_kilobyte_is_1024_bytes=True):
|
||||
<samp class=p>>>> </samp><kbd>"{0:.1f} {1}".format(698.25, 'GB')</kbd>
|
||||
<samp>'698.3 GB'</samp></pre>
|
||||
|
||||
<p>For all the gory details on format specifiers, consult the <a href="http://docs.python.org/dev/3.0/library/string.html#format-specification-mini-language">Format Specification Mini-Language</a> in the official Python documentation.
|
||||
<p>For all the gory details on format specifiers, consult the <a href="http://docs.python.org/3.0/library/string.html#format-specification-mini-language">Format Specification Mini-Language</a> in the official Python documentation.
|
||||
|
||||
<h2 id=common-string-methods>Other Common String Methods</h2>
|
||||
|
||||
@@ -359,8 +359,8 @@ is an object. You might have thought I meant that string <em>variables</em> are
|
||||
<p>On Unicode in Python:
|
||||
|
||||
<ul>
|
||||
<li><a href="http://docs.python.org/dev/3.0/howto/unicode.html">Python Unicode HOWTO</a>
|
||||
<li><a href="http://docs.python.org/dev/3.0/whatsnew/3.0.html#text-vs-data-instead-of-unicode-vs-8-bit">What's New In Python 3: Text vs. Data Instead Of Unicode vs. 8-bit</a>
|
||||
<li><a href="http://docs.python.org/3.0/howto/unicode.html">Python Unicode HOWTO</a>
|
||||
<li><a href="http://docs.python.org/3.0/whatsnew/3.0.html#text-vs-data-instead-of-unicode-vs-8-bit">What's New In Python 3: Text vs. Data Instead Of Unicode vs. 8-bit</a>
|
||||
</ul>
|
||||
|
||||
<p>On Unicode in general:
|
||||
@@ -382,9 +382,9 @@ is an object. You might have thought I meant that string <em>variables</em> are
|
||||
<p>On strings and string formatting:
|
||||
|
||||
<ul>
|
||||
<li><a href="http://docs.python.org/dev/3.0/library/string.html"><code>string</code> — Common string operations</a>
|
||||
<li><a href="http://docs.python.org/dev/3.0/library/string.html#formatstrings">Format String Syntax</a>
|
||||
<li><a href="http://docs.python.org/dev/3.0/library/string.html#format-specification-mini-language">Format Specification Mini-Language</a>
|
||||
<li><a href="http://docs.python.org/3.0/library/string.html"><code>string</code> — Common string operations</a>
|
||||
<li><a href="http://docs.python.org/3.0/library/string.html#formatstrings">Format String Syntax</a>
|
||||
<li><a href="http://docs.python.org/3.0/library/string.html#format-specification-mini-language">Format Specification Mini-Language</a>
|
||||
<li><a href="http://www.python.org/dev/peps/pep-3101/"><abbr>PEP</abbr> 3101: Advanced String Formatting</a>
|
||||
</ul>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user