mirror of
https://github.com/kennethreitz/dive-into-python3.git
synced 2026-06-05 23:10:17 +00:00
converted case-study-porting-chardet-to-python-3 to HTML
This commit is contained in:
@@ -346,7 +346,7 @@ several months behind in updating their ActivePython installer when new version
|
||||
<samp class="computeroutput">PythonWin 2.2.2 (#37, Nov 26 2002, 10:24:37) [MSC 32 bit (Intel)] on win32.
|
||||
Portions Copyright 1994-2001 Mark Hammond (mhammond@skippinet.com.au) -
|
||||
see 'Help/About PythonWin' for further copyright information.</samp>
|
||||
<samp> class="prompt">>>> </samp>
|
||||
<samp class="prompt">>>> </samp>
|
||||
</pre></div>
|
||||
<div class="procedure">
|
||||
<h3 class="title">Procedure 1.2. Option 2: Installing Python from <a href="http://www.python.org/" title="Python language home page">Python.org</a></h3>
|
||||
@@ -383,7 +383,7 @@ Type "copyright", "credits" or "license()" for more information.
|
||||
****************************************************************
|
||||
|
||||
IDLE 1.0</samp>
|
||||
<samp> class="prompt">>>> </samp>
|
||||
<samp class="prompt">>>> </samp>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="section">
|
||||
@@ -418,7 +418,7 @@ Welcome to Darwin!
|
||||
<samp class="computeroutput">Python 2.2 (#1, 07/14/02, 23:25:09)
|
||||
[GCC Apple cpp-precomp 6.14] on darwin
|
||||
Type "help", "copyright", "credits", or "license" for more information.</samp>
|
||||
<samp> class="prompt">>>> </samp>[press Ctrl+D to get back to the command prompt]
|
||||
<samp class="prompt">>>> </samp>[press Ctrl+D to get back to the command prompt]
|
||||
<samp class="prompt">[localhost:~] you% </samp>
|
||||
</pre></div>
|
||||
<div class="procedure">
|
||||
@@ -458,7 +458,7 @@ Window->Python Interactive (<kbd class="shortcut">Cmd-0</kbd>). The opening win
|
||||
[GCC 3.1 20020420 (prerelease)]
|
||||
Type "copyright", "credits" or "license" for more information.
|
||||
MacPython IDE 1.0.1</samp>
|
||||
<samp> class="prompt">>>> </samp>
|
||||
<samp class="prompt">>>> </samp>
|
||||
</pre></div>
|
||||
<p>Note that once you install the latest version, the pre-installed version is still present. If you are running scripts from
|
||||
the command line, you need to be aware which version of Python you are using.</p>
|
||||
@@ -467,12 +467,12 @@ the command line, you need to be aware which version of Python you are using.</p
|
||||
<samp class="computeroutput">Python 2.2 (#1, 07/14/02, 23:25:09)
|
||||
[GCC Apple cpp-precomp 6.14] on darwin
|
||||
Type "help", "copyright", "credits", or "license" for more information.</samp>
|
||||
<samp> class="prompt">>>> </samp>[press Ctrl+D to get back to the command prompt]
|
||||
<samp class="prompt">>>> </samp>[press Ctrl+D to get back to the command prompt]
|
||||
<samp class="prompt">[localhost:~] you% </samp>/usr/local/bin/python
|
||||
<samp class="computeroutput">Python 2.3 (#2, Jul 30 2003, 11:45:28)
|
||||
[GCC 3.1 20020420 (prerelease)] on darwin
|
||||
Type "help", "copyright", "credits", or "license" for more information.</samp>
|
||||
<samp> class="prompt">>>> </samp>[press Ctrl+D to get back to the command prompt]
|
||||
<samp class="prompt">>>> </samp>[press Ctrl+D to get back to the command prompt]
|
||||
<samp class="prompt">[localhost:~] you% </samp>
|
||||
</pre></div>
|
||||
</div>
|
||||
@@ -512,7 +512,7 @@ Window->Python Interactive (<kbd class="shortcut">Cmd-0</kbd>). You'll see a sc
|
||||
[GCC 3.1 20020420 (prerelease)]
|
||||
Type "copyright", "credits" or "license" for more information.
|
||||
MacPython IDE 1.0.1</samp>
|
||||
<samp> class="prompt">>>> </samp>
|
||||
<samp class="prompt">>>> </samp>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="section">
|
||||
@@ -529,19 +529,19 @@ Connecting to python.org[194.109.137.226]:80... connected.
|
||||
HTTP request sent, awaiting response... 200 OK
|
||||
Length: 7,495,111 [application/octet-stream]
|
||||
...</samp>
|
||||
<samp> class="prompt">[root@localhost root]# </samp>rpm -Uvh python2.3-2.3-5pydotorg.i386.rpm
|
||||
<samp class="prompt">[root@localhost root]# </samp>rpm -Uvh python2.3-2.3-5pydotorg.i386.rpm
|
||||
<samp class="computeroutput">Preparing... ########################################### [100%]
|
||||
1:python2.3 ########################################### [100%]</samp>
|
||||
<samp> class="prompt">[root@localhost root]# </samp>python <img id="install.unix.1.1" src="images/callouts/1.png" alt="1" border="0" width="12" height="12">
|
||||
<samp class="prompt">[root@localhost root]# </samp>python <img id="install.unix.1.1" src="images/callouts/1.png" alt="1" border="0" width="12" height="12">
|
||||
<samp class="computeroutput">Python 2.2.2 (#1, Feb 24 2003, 19:13:11)
|
||||
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-4)] on linux2
|
||||
Type "help", "copyright", "credits", or "license" for more information.</samp>
|
||||
<samp> class="prompt">>>> </samp>[press Ctrl+D to exit]
|
||||
<samp class="prompt">>>> </samp>[press Ctrl+D to exit]
|
||||
<samp class="prompt">[root@localhost root]# </samp>python2.3 <img id="install.unix.1.2" src="images/callouts/2.png" alt="2" border="0" width="12" height="12">
|
||||
<samp class="computeroutput">Python 2.3 (#1, Sep 12 2003, 10:53:56)
|
||||
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)] on linux2
|
||||
Type "help", "copyright", "credits", or "license" for more information.</samp>
|
||||
<samp> class="prompt">>>> </samp>[press Ctrl+D to exit]
|
||||
<samp class="prompt">>>> </samp>[press Ctrl+D to exit]
|
||||
<samp class="prompt">[root@localhost root]# </samp>which python2.3 <img id="install.unix.1.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12">
|
||||
/usr/bin/python2.3
|
||||
</pre><div class="calloutlist">
|
||||
@@ -586,7 +586,7 @@ The following NEW packages will be installed:
|
||||
0 upgraded, 2 newly installed, 0 to remove and 3 not upgraded.
|
||||
Need to get 0B/2880kB of archives.
|
||||
After unpacking 9351kB of additional disk space will be used.</samp>
|
||||
<samp> class="prompt">Do you want to continue? [Y/n] </samp>Y
|
||||
<samp class="prompt">Do you want to continue? [Y/n] </samp>Y
|
||||
<samp class="computeroutput">Selecting previously deselected package python2.3.
|
||||
(Reading database ... 22848 files and directories currently installed.)
|
||||
Unpacking python2.3 (from .../python2.3_2.3.1-1_i386.deb) ...
|
||||
@@ -596,13 +596,13 @@ Setting up python (2.3.1-1) ...
|
||||
Setting up python2.3 (2.3.1-1) ...
|
||||
Compiling python modules in /usr/lib/python2.3 ...
|
||||
Compiling optimized python modules in /usr/lib/python2.3 ...</samp>
|
||||
<samp> class="prompt">localhost:~# </samp>exit
|
||||
<samp class="prompt">localhost:~# </samp>exit
|
||||
logout
|
||||
<samp class="prompt">localhost:~$ </samp>python
|
||||
<samp class="computeroutput">Python 2.3.1 (#2, Sep 24 2003, 11:39:14)
|
||||
[GCC 3.3.2 20030908 (Debian prerelease)] on linux2
|
||||
Type "help", "copyright", "credits" or "license" for more information.</samp>
|
||||
<samp> class="prompt">>>> </samp>[press Ctrl+D to exit]
|
||||
<samp class="prompt">>>> </samp>[press Ctrl+D to exit]
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="section">
|
||||
@@ -617,14 +617,14 @@ Connecting to www.python.org[194.109.137.226]:80... connected.
|
||||
HTTP request sent, awaiting response... 200 OK
|
||||
Length: 8,436,880 [application/x-tar]
|
||||
...</samp>
|
||||
<samp> class="prompt">localhost:~# </samp>tar xfz Python-2.3.tgz
|
||||
<samp class="prompt">localhost:~# </samp>tar xfz Python-2.3.tgz
|
||||
<samp class="prompt">localhost:~# </samp>cd Python-2.3
|
||||
<samp class="prompt">localhost:~/Python-2.3# </samp>./configure
|
||||
<samp class="computeroutput">checking MACHDEP... linux2
|
||||
checking EXTRAPLATDIR...
|
||||
checking for --without-gcc... no
|
||||
...</samp>
|
||||
<samp> class="prompt">localhost:~/Python-2.3# </samp>make
|
||||
<samp class="prompt">localhost:~/Python-2.3# </samp>make
|
||||
<samp class="computeroutput">gcc -pthread -c -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes
|
||||
-I. -I./Include -DPy_BUILD_CORE -o Modules/python.o Modules/python.c
|
||||
gcc -pthread -c -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes
|
||||
@@ -632,10 +632,10 @@ gcc -pthread -c -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes
|
||||
gcc -pthread -c -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes
|
||||
-I. -I./Include -DPy_BUILD_CORE -o Parser/grammar1.o Parser/grammar1.c
|
||||
...</samp>
|
||||
<samp> class="prompt">localhost:~/Python-2.3# </samp>make install
|
||||
<samp class="prompt">localhost:~/Python-2.3# </samp>make install
|
||||
<samp class="computeroutput">/usr/bin/install -c python /usr/local/bin/python2.3
|
||||
...</samp>
|
||||
<samp> class="prompt">localhost:~/Python-2.3# </samp>exit
|
||||
<samp class="prompt">localhost:~/Python-2.3# </samp>exit
|
||||
logout
|
||||
<samp class="prompt">localhost:~$ </samp>which python
|
||||
/usr/local/bin/python
|
||||
@@ -643,7 +643,7 @@ logout
|
||||
<samp class="computeroutput">Python 2.3.1 (#2, Sep 24 2003, 11:39:14)
|
||||
[GCC 3.3.2 20030908 (Debian prerelease)] on linux2
|
||||
Type "help", "copyright", "credits" or "license" for more information.</samp>
|
||||
<samp> class="prompt">>>> </samp>[press Ctrl+D to get back to the command prompt]
|
||||
<samp class="prompt">>>> </samp>[press Ctrl+D to get back to the command prompt]
|
||||
<samp class="prompt">localhost:~$ </samp>
|
||||
</pre></div>
|
||||
</div>
|
||||
@@ -892,7 +892,7 @@ Returns string.</span></pre><div class="calloutlist">
|
||||
<samp class="computeroutput">['', '/usr/local/lib/python2.2', '/usr/local/lib/python2.2/plat-linux2',
|
||||
'/usr/local/lib/python2.2/lib-dynload', '/usr/local/lib/python2.2/site-packages',
|
||||
'/usr/local/lib/python2.2/site-packages/PIL', '/usr/local/lib/python2.2/site-packages/piddle']</samp>
|
||||
<samp> class="prompt">>>> </samp>sys <img id="odbchelper.objects.2.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>sys <img id="odbchelper.objects.2.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12">
|
||||
<module 'sys' (built-in)>
|
||||
<samp class="prompt">>>> </samp>sys.path.append('/my/new/path') <img id="odbchelper.objects.2.4" src="images/callouts/4.png" alt="4" border="0" width="12" height="12"></pre><div class="calloutlist">
|
||||
<table border="0" summary="Callout list">
|
||||
@@ -1227,7 +1227,7 @@ KeyError: mpilgrim</span></pre><div class="calloutlist">
|
||||
<div class="example"><h3 id="odbchelper.dict.del" class="title">Example 3.5. Deleting Items from a Dictionary</h3><pre class="screen"><samp class="prompt">>>> </samp>d
|
||||
<samp class="computeroutput">{'server': 'mpilgrim', 'uid': 'sa', 'database': 'master',
|
||||
42: 'douglas', 'retrycount': 3}</samp>
|
||||
<samp> class="prompt">>>> </samp>del d[42] <img id="odbchelper.dict.4.1" src="images/callouts/1.png" alt="1" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>del d[42] <img id="odbchelper.dict.4.1" src="images/callouts/1.png" alt="1" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>d
|
||||
{'server': 'mpilgrim', 'uid': 'sa', 'database': 'master', 'retrycount': 3}
|
||||
<samp class="prompt">>>> </samp>d.clear() <img id="odbchelper.dict.4.2" src="images/callouts/2.png" alt="2" border="0" width="12" height="12">
|
||||
@@ -1504,7 +1504,7 @@ KeyError: mpilgrim</span></pre><div class="calloutlist">
|
||||
<samp class="traceback">Traceback (innermost last):
|
||||
File "<interactive input>", line 1, in ?
|
||||
ValueError: list.index(x): x not in list</samp>
|
||||
<samp> class="prompt">>>> </samp>"c" in li <img id="odbchelper.list.6.4" src="images/callouts/4.png" alt="4" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>"c" in li <img id="odbchelper.list.6.4" src="images/callouts/4.png" alt="4" border="0" width="12" height="12">
|
||||
False</pre><div class="calloutlist">
|
||||
<table border="0" summary="Callout list">
|
||||
<tr>
|
||||
@@ -1573,7 +1573,7 @@ False</pre><div class="calloutlist">
|
||||
<samp class="traceback">Traceback (innermost last):
|
||||
File "<interactive input>", line 1, in ?
|
||||
ValueError: list.remove(x): x not in list</samp>
|
||||
<samp> class="prompt">>>> </samp>li.pop() <img id="odbchelper.list.7.4" src="images/callouts/4.png" alt="4" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>li.pop() <img id="odbchelper.list.7.4" src="images/callouts/4.png" alt="4" border="0" width="12" height="12">
|
||||
'elements'
|
||||
<samp class="prompt">>>> </samp>li
|
||||
['a', 'b', 'mpilgrim', 'example', 'new', 'two']</pre><div class="calloutlist">
|
||||
@@ -1705,15 +1705,15 @@ ValueError: list.remove(x): x not in list</samp>
|
||||
<samp class="traceback">Traceback (innermost last):
|
||||
File "<interactive input>", line 1, in ?
|
||||
AttributeError: 'tuple' object has no attribute 'append'</samp>
|
||||
<samp> class="prompt">>>> </samp>t.remove("z") <img id="odbchelper.tuple.2.2" src="images/callouts/2.png" alt="2" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>t.remove("z") <img id="odbchelper.tuple.2.2" src="images/callouts/2.png" alt="2" border="0" width="12" height="12">
|
||||
<samp class="traceback">Traceback (innermost last):
|
||||
File "<interactive input>", line 1, in ?
|
||||
AttributeError: 'tuple' object has no attribute 'remove'</samp>
|
||||
<samp> class="prompt">>>> </samp>t.index("example") <img id="odbchelper.tuple.2.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>t.index("example") <img id="odbchelper.tuple.2.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12">
|
||||
<samp class="traceback">Traceback (innermost last):
|
||||
File "<interactive input>", line 1, in ?
|
||||
AttributeError: 'tuple' object has no attribute 'index'</samp>
|
||||
<samp> class="prompt">>>> </samp>"z" in t <img id="odbchelper.tuple.2.4" src="images/callouts/4.png" alt="4" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>"z" in t <img id="odbchelper.tuple.2.4" src="images/callouts/4.png" alt="4" border="0" width="12" height="12">
|
||||
True</pre><div class="calloutlist">
|
||||
<table border="0" summary="Callout list">
|
||||
<tr>
|
||||
@@ -1809,7 +1809,7 @@ a matter of style.</p>
|
||||
<samp class="traceback">Traceback (innermost last):
|
||||
File "<interactive input>", line 1, in ?
|
||||
NameError: There is no variable named 'x'</samp>
|
||||
<samp> class="prompt">>>> </samp>x = 1
|
||||
<samp class="prompt">>>> </samp>x = 1
|
||||
<samp class="prompt">>>> </samp>x
|
||||
1</pre></div>
|
||||
<p>You will thank Python for this one day.</p>
|
||||
@@ -2487,7 +2487,7 @@ True</pre><div class="calloutlist">
|
||||
<samp class="prompt">>>> </samp>dir(li) <img id="apihelper.builtin.3.1" src="images/callouts/1.png" alt="1" border="0" width="12" height="12">
|
||||
<samp class="computeroutput">['append', 'count', 'extend', 'index', 'insert',
|
||||
'pop', 'remove', 'reverse', 'sort']</samp>
|
||||
<samp> class="prompt">>>> </samp>d = {}
|
||||
<samp class="prompt">>>> </samp>d = {}
|
||||
<samp class="prompt">>>> </samp>dir(d) <img id="apihelper.builtin.3.2" src="images/callouts/2.png" alt="2" border="0" width="12" height="12">
|
||||
['clear', 'copy', 'get', 'has_key', 'items', 'keys', 'setdefault', 'update', 'values']
|
||||
<samp class="prompt">>>> </samp>import odbchelper
|
||||
@@ -3035,7 +3035,7 @@ a <code class="literal">lambda</code> function; if you need something more compl
|
||||
<samp class="prompt">>>> </samp>print s
|
||||
<samp class="computeroutput">this is
|
||||
a test</samp>
|
||||
<samp> class="prompt">>>> </samp>print s.split() <img id="apihelper.split.1.2" src="images/callouts/2.png" alt="2" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>print s.split() <img id="apihelper.split.1.2" src="images/callouts/2.png" alt="2" border="0" width="12" height="12">
|
||||
['this', 'is', 'a', 'test']
|
||||
<samp class="prompt">>>> </samp>print " ".join(s.split()) <img id="apihelper.split.1.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12">
|
||||
'this is a test'</pre><div class="calloutlist">
|
||||
@@ -3450,7 +3450,7 @@ can import individual items or use <code class="literal">from <i class="replacea
|
||||
<samp class="traceback">Traceback (innermost last):
|
||||
File "<interactive input>", line 1, in ?
|
||||
NameError: There is no variable named 'FunctionType'</samp>
|
||||
<samp> class="prompt">>>> </samp>from types import FunctionType <img id="fileinfo.import.1.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>from types import FunctionType <img id="fileinfo.import.1.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>FunctionType <img id="fileinfo.import.1.4" src="images/callouts/4.png" alt="4" border="0" width="12" height="12">
|
||||
<type 'function'></pre><div class="calloutlist">
|
||||
<table border="0" summary="Callout list">
|
||||
@@ -4077,7 +4077,7 @@ provide a way to map non-method-calling syntax into method calls.</p>
|
||||
<samp class="computeroutput">{'album': 'Rave Mix', 'artist': '***DJ MARY-JANE***', 'genre': 31,
|
||||
'title': 'KAIRO****THE BEST GOA', 'name': '/music/_singles/kairo.mp3',
|
||||
'year': '2000', 'comment': 'http://mp3.com/DJMARYJANE'}</samp>
|
||||
<samp> class="prompt">>>> </samp>mp3file["name"] = "/music/_singles/sidewinder.mp3" <img id="fileinfo.specialmethods.4.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>mp3file["name"] = "/music/_singles/sidewinder.mp3" <img id="fileinfo.specialmethods.4.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>mp3file
|
||||
<samp class="computeroutput">{'album': '', 'artist': 'The Cynic Project', 'genre': 18, 'title': 'Sidewinder',
|
||||
'name': '/music/_singles/sidewinder.mp3', 'year': '2000',
|
||||
@@ -4206,7 +4206,7 @@ class MP3FileInfo(FileInfo):
|
||||
'year': (93, 97, <function stripnulls at 0260C8D4>),
|
||||
'comment': (97, 126, <function stripnulls at 0260C8D4>),
|
||||
'album': (63, 93, <function stripnulls at 0260C8D4>)}</samp>
|
||||
<samp> class="prompt">>>> </samp>m = fileinfo.MP3FileInfo() <img id="fileinfo.classattributes.1.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>m = fileinfo.MP3FileInfo() <img id="fileinfo.classattributes.1.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>m.tagDataMap
|
||||
<samp class="computeroutput">{'title': (3, 33, <function stripnulls at 0260C8D4>),
|
||||
'genre': (127, 128, <built-in function ord>),
|
||||
@@ -4421,7 +4421,7 @@ a line of code may raise an exception, you should handle the exception using a <
|
||||
<samp class="traceback">Traceback (innermost last):
|
||||
File "<interactive input>", line 1, in ?
|
||||
IOError: [Errno 2] No such file or directory: '/notthere'</samp>
|
||||
<samp> class="prompt">>>> </samp>try:
|
||||
<samp class="prompt">>>> </samp>try:
|
||||
<samp class="prompt">... </samp>fsock = open("/notthere") <img id="fileinfo.exceptions.1.2" src="images/callouts/2.png" alt="2" border="0" width="12" height="12">
|
||||
<samp class="prompt">... </samp>except IOError: <img id="fileinfo.exceptions.1.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12">
|
||||
<samp class="prompt">... </samp>print "The file does not exist, exiting gracefully"
|
||||
@@ -4597,7 +4597,7 @@ exceptions, errors occur immediately, and you can handle them in a standard way
|
||||
<samp class="prompt">>>> </samp>tagData
|
||||
<samp class="computeroutput">'TAGKAIRO****THE BEST GOA ***DJ MARY-JANE***
|
||||
Rave Mix 2000http://mp3.com/DJMARYJANE \037'</samp>
|
||||
<samp> class="prompt">>>> </samp>f.tell() <img id="fileinfo.files.2.5" src="images/callouts/5.png" alt="5" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>f.tell() <img id="fileinfo.files.2.5" src="images/callouts/5.png" alt="5" border="0" width="12" height="12">
|
||||
7543037</pre><div class="calloutlist">
|
||||
<table border="0" summary="Callout list">
|
||||
<tr>
|
||||
@@ -4657,15 +4657,15 @@ True
|
||||
<samp class="traceback">Traceback (innermost last):
|
||||
File "<interactive input>", line 1, in ?
|
||||
ValueError: I/O operation on closed file</samp>
|
||||
<samp> class="prompt">>>> </samp>f.tell()
|
||||
<samp class="prompt">>>> </samp>f.tell()
|
||||
<samp class="traceback">Traceback (innermost last):
|
||||
File "<interactive input>", line 1, in ?
|
||||
ValueError: I/O operation on closed file</samp>
|
||||
<samp> class="prompt">>>> </samp>f.read()
|
||||
<samp class="prompt">>>> </samp>f.read()
|
||||
<samp class="traceback">Traceback (innermost last):
|
||||
File "<interactive input>", line 1, in ?
|
||||
ValueError: I/O operation on closed file</samp>
|
||||
<samp> class="prompt">>>> </samp>f.close() <img id="fileinfo.files.3.5" src="images/callouts/5.png" alt="5" border="0" width="12" height="12"></pre><div class="calloutlist">
|
||||
<samp class="prompt">>>> </samp>f.close() <img id="fileinfo.files.3.5" src="images/callouts/5.png" alt="5" border="0" width="12" height="12"></pre><div class="calloutlist">
|
||||
<table border="0" summary="Callout list">
|
||||
<tr>
|
||||
<td width="12" valign="top" align="left"><a href="#fileinfo.files.3.1"><img src="images/callouts/1.png" alt="1" border="0" width="12" height="12"></a>
|
||||
@@ -4849,7 +4849,7 @@ or other iteratable entities. But in Python, a <code class="literal">for</code>
|
||||
<samp class="computeroutput">a
|
||||
b
|
||||
e</samp>
|
||||
<samp> class="prompt">>>> </samp>print "\n".join(li) <img id="fileinfo.for.1.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>print "\n".join(li) <img id="fileinfo.for.1.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12">
|
||||
<samp class="computeroutput">a
|
||||
b
|
||||
e</span></pre><div class="calloutlist">
|
||||
@@ -4884,7 +4884,7 @@ e</span></pre><div class="calloutlist">
|
||||
2
|
||||
3
|
||||
4</samp>
|
||||
<samp> class="prompt">>>> </samp>li = ['a', 'b', 'c', 'd', 'e']
|
||||
<samp class="prompt">>>> </samp>li = ['a', 'b', 'c', 'd', 'e']
|
||||
<samp class="prompt">>>> </samp>for i in range(len(li)): <img id="fileinfo.for.3.2" src="images/callouts/2.png" alt="2" border="0" width="12" height="12">
|
||||
<samp class="prompt">... </samp>print li[i]
|
||||
<samp class="computeroutput">a
|
||||
@@ -4921,7 +4921,7 @@ COMPUTERNAME=MPILGRIM
|
||||
USERNAME=mpilgrim
|
||||
|
||||
[...snip...]</samp>
|
||||
<samp> class="prompt">>>> </samp>print "\n".join(["%s=%s" % (k, v)
|
||||
<samp class="prompt">>>> </samp>print "\n".join(["%s=%s" % (k, v)
|
||||
<samp class="prompt">... </samp>for k, v in os.environ.items()]) <img id="fileinfo.for.2.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12">
|
||||
<samp class="computeroutput">USERPROFILE=C:\Documents and Settings\mpilgrim
|
||||
OS=Windows_NT
|
||||
@@ -5044,7 +5044,7 @@ site
|
||||
signal
|
||||
UserDict
|
||||
stat</samp>
|
||||
<samp> class="prompt">>>> </samp>fileinfo
|
||||
<samp class="prompt">>>> </samp>fileinfo
|
||||
<module 'fileinfo' from 'fileinfo.pyc'>
|
||||
<samp class="prompt">>>> </samp>sys.modules["fileinfo"] <img id="fileinfo.modules.1.4" src="images/callouts/2.png" alt="2" border="0" width="12" height="12">
|
||||
<module 'fileinfo' from 'fileinfo.pyc'></pre><div class="calloutlist">
|
||||
@@ -5228,18 +5228,18 @@ stat</samp>
|
||||
<samp class="computeroutput">['a_time_long_forgotten_con.mp3', 'hellraiser.mp3',
|
||||
'kairo.mp3', 'long_way_home1.mp3', 'sidewinder.mp3',
|
||||
'spinning.mp3']</samp>
|
||||
<samp> class="prompt">>>> </samp>dirname = "c:\\"
|
||||
<samp class="prompt">>>> </samp>dirname = "c:\\"
|
||||
<samp class="prompt">>>> </samp>os.listdir(dirname) <img id="fileinfo.os.3.2" src="images/callouts/2.png" alt="2" border="0" width="12" height="12">
|
||||
<samp class="computeroutput">['AUTOEXEC.BAT', 'boot.ini', 'CONFIG.SYS', 'cygwin',
|
||||
'docbook', 'Documents and Settings', 'Incoming', 'Inetpub', 'IO.SYS',
|
||||
'MSDOS.SYS', 'Music', 'NTDETECT.COM', 'ntldr', 'pagefile.sys',
|
||||
'Program Files', 'Python20', 'RECYCLER',
|
||||
'System Volume Information', 'TEMP', 'WINNT']</samp>
|
||||
<samp> class="prompt">>>> </samp>[f for f in os.listdir(dirname)
|
||||
<samp class="prompt">>>> </samp>[f for f in os.listdir(dirname)
|
||||
<samp class="prompt">... </samp>if os.path.isfile(os.path.join(dirname, f))] <img id="fileinfo.os.3.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12">
|
||||
<samp class="computeroutput">['AUTOEXEC.BAT', 'boot.ini', 'CONFIG.SYS', 'IO.SYS', 'MSDOS.SYS',
|
||||
'NTDETECT.COM', 'ntldr', 'pagefile.sys']</samp>
|
||||
<samp> class="prompt">>>> </samp>[f for f in os.listdir(dirname)
|
||||
<samp class="prompt">>>> </samp>[f for f in os.listdir(dirname)
|
||||
<samp class="prompt">... </samp>if os.path.isdir(os.path.join(dirname, f))] <img id="fileinfo.os.3.4" src="images/callouts/4.png" alt="4" border="0" width="12" height="12">
|
||||
<samp class="computeroutput">['cygwin', 'docbook', 'Documents and Settings', 'Incoming',
|
||||
'Inetpub', 'Music', 'Program Files', 'Python20', 'RECYCLER',
|
||||
@@ -5331,7 +5331,7 @@ may already be familiar with from working on the command line.</p>
|
||||
<samp class="computeroutput">['a_time_long_forgotten_con.mp3', 'hellraiser.mp3',
|
||||
'kairo.mp3', 'long_way_home1.mp3', 'sidewinder.mp3',
|
||||
'spinning.mp3']</samp>
|
||||
<samp> class="prompt">>>> </samp>import glob
|
||||
<samp class="prompt">>>> </samp>import glob
|
||||
<samp class="prompt">>>> </samp>glob.glob('c:\\music\\_singles\\*.mp3') <img id="fileinfo.os.4.2" src="images/callouts/2.png" alt="2" border="0" width="12" height="12">
|
||||
<samp class="computeroutput">['c:\\music\\_singles\\a_time_long_forgotten_con.mp3',
|
||||
'c:\\music\\_singles\\hellraiser.mp3',
|
||||
@@ -5339,10 +5339,10 @@ may already be familiar with from working on the command line.</p>
|
||||
'c:\\music\\_singles\\long_way_home1.mp3',
|
||||
'c:\\music\\_singles\\sidewinder.mp3',
|
||||
'c:\\music\\_singles\\spinning.mp3']</samp>
|
||||
<samp> class="prompt">>>> </samp>glob.glob('c:\\music\\_singles\\s*.mp3') <img id="fileinfo.os.4.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>glob.glob('c:\\music\\_singles\\s*.mp3') <img id="fileinfo.os.4.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12">
|
||||
<samp class="computeroutput">['c:\\music\\_singles\\sidewinder.mp3',
|
||||
'c:\\music\\_singles\\spinning.mp3']</samp>
|
||||
<samp> class="prompt">>>> </samp>glob.glob('c:\\music\\*\\*.mp3')<img id="fileinfo.os.4.4" src="images/callouts/4.png" alt="4" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>glob.glob('c:\\music\\*\\*.mp3')<img id="fileinfo.os.4.4" src="images/callouts/4.png" alt="4" border="0" width="12" height="12">
|
||||
</pre><div class="calloutlist">
|
||||
<table border="0" summary="Callout list">
|
||||
<tr>
|
||||
@@ -6100,7 +6100,7 @@ it a verbose regular expression. This example shows how.</p>
|
||||
# or 5-8 (V, followed by 0 to 3 I's)
|
||||
$ # end of string
|
||||
"""</kbd>
|
||||
<samp> class="prompt">>>> </samp>re.search(pattern, 'M', re.VERBOSE) <img id="re.verbose.1.1" src="images/callouts/1.png" alt="1" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>re.search(pattern, 'M', re.VERBOSE) <img id="re.verbose.1.1" src="images/callouts/1.png" alt="1" border="0" width="12" height="12">
|
||||
<_sre.SRE_Match object at 0x008EEB48>
|
||||
<samp class="prompt">>>> </samp>re.search(pattern, 'MCMLXXXIX', re.VERBOSE) <img id="re.verbose.1.2" src="images/callouts/2.png" alt="2" border="0" width="12" height="12">
|
||||
<_sre.SRE_Match object at 0x008EEB48>
|
||||
@@ -6440,7 +6440,7 @@ you made.</p>
|
||||
(\d*) # extension is optional and can be any number of digits
|
||||
$ # end of string
|
||||
''', re.VERBOSE)</kbd>
|
||||
<samp> class="prompt">>>> </samp>phonePattern.search('work 1-(800) 555.1212 #1234').groups() <img id="re.phone.7.1" src="images/callouts/1.png" alt="1" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>phonePattern.search('work 1-(800) 555.1212 #1234').groups() <img id="re.phone.7.1" src="images/callouts/1.png" alt="1" border="0" width="12" height="12">
|
||||
('800', '555', '1212', '1234')
|
||||
<samp class="prompt">>>> </samp>phonePattern.search('800-555-1212') <img id="re.phone.7.2" src="images/callouts/2.png" alt="2" border="0" width="12" height="12">
|
||||
('800', '555', '1212', '')
|
||||
@@ -8366,21 +8366,21 @@ package architecture. It's one of the many things Python is good at, so take ad
|
||||
<samp class="prompt">>>> </samp>grammarNode.childNodes<img id="kgp.parse.4.1" src="images/callouts/1.png" alt="1" border="0" width="12" height="12">
|
||||
<samp class="computeroutput">[<DOM Text node "\n">, <DOM Element: ref at 17533332>, \
|
||||
<DOM Text node "\n">, <DOM Element: ref at 17549660>, <DOM Text node "\n">]</samp>
|
||||
<samp> class="prompt">>>> </samp>print grammarNode.firstChild.toxml() <img id="kgp.parse.4.2" src="images/callouts/2.png" alt="2" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>print grammarNode.firstChild.toxml() <img id="kgp.parse.4.2" src="images/callouts/2.png" alt="2" border="0" width="12" height="12">
|
||||
<samp class="computeroutput">
|
||||
|
||||
</samp>
|
||||
<samp> class="prompt">>>> </samp>print grammarNode.childNodes[1].toxml() <img id="kgp.parse.4.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>print grammarNode.childNodes[1].toxml() <img id="kgp.parse.4.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12">
|
||||
<samp class="computeroutput"><ref id="bit">
|
||||
<p>0</p>
|
||||
<p>1</p>
|
||||
</ref></samp>
|
||||
<samp> class="prompt">>>> </samp>print grammarNode.childNodes[3].toxml() <img id="kgp.parse.4.4" src="images/callouts/4.png" alt="4" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>print grammarNode.childNodes[3].toxml() <img id="kgp.parse.4.4" src="images/callouts/4.png" alt="4" border="0" width="12" height="12">
|
||||
<samp class="computeroutput"><ref id="byte">
|
||||
<p><xref id="bit"/><xref id="bit"/><xref id="bit"/><xref id="bit"/>\
|
||||
<xref id="bit"/><xref id="bit"/><xref id="bit"/><xref id="bit"/></p>
|
||||
</ref></samp>
|
||||
<samp> class="prompt">>>> </samp>print grammarNode.lastChild.toxml() <img id="kgp.parse.4.5" src="images/callouts/5.png" alt="5" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>print grammarNode.lastChild.toxml() <img id="kgp.parse.4.5" src="images/callouts/5.png" alt="5" border="0" width="12" height="12">
|
||||
<samp class="computeroutput">
|
||||
|
||||
</span></pre><div class="calloutlist">
|
||||
@@ -8428,7 +8428,7 @@ package architecture. It's one of the many things Python is good at, so take ad
|
||||
<samp class="computeroutput">[<DOM Text node "\n">, <DOM Text node " ">, <DOM Element: p at 19315844>, \
|
||||
<DOM Text node "\n">, <DOM Text node " ">, \
|
||||
<DOM Element: p at 19462036>, <DOM Text node "\n">]</samp>
|
||||
<samp> class="prompt">>>> </samp>pNode = refNode.childNodes[2]
|
||||
<samp class="prompt">>>> </samp>pNode = refNode.childNodes[2]
|
||||
<samp class="prompt">>>> </samp>pNode
|
||||
<DOM Element: p at 19315844>
|
||||
<samp class="prompt">>>> </samp>print pNode.toxml() <img id="kgp.parse.5.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12">
|
||||
@@ -8525,7 +8525,7 @@ Dive in</pre><div class="calloutlist">
|
||||
<samp class="traceback">Traceback (innermost last):
|
||||
File "<interactive input>", line 1, in ?
|
||||
UnicodeError: ASCII encoding error: ordinal not in range(128)</samp>
|
||||
<samp> class="prompt">>>> </samp>print s.encode('latin-1') <img id="kgp.unicode.2.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>print s.encode('latin-1') <img id="kgp.unicode.2.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12">
|
||||
La Peña</pre><div class="calloutlist">
|
||||
<table border="0" summary="Callout list">
|
||||
<tr>
|
||||
@@ -8639,7 +8639,7 @@ u'\u041f\u0440\u0435\u0434\u0438\u0441\u043b\u043e\u0432\u0438\u0435'
|
||||
<samp class="traceback">Traceback (innermost last):
|
||||
File "<interactive input>", line 1, in ?
|
||||
UnicodeError: ASCII encoding error: ordinal not in range(128)</samp>
|
||||
<samp> class="prompt">>>> </samp>convertedtitle = title.encode('koi8-r') <img id="kgp.unicode.6.4" src="images/callouts/4.png" alt="4" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>convertedtitle = title.encode('koi8-r') <img id="kgp.unicode.6.4" src="images/callouts/4.png" alt="4" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>convertedtitle
|
||||
'\xf0\xd2\xc5\xc4\xc9\xd3\xcc\xcf\xd7\xc9\xc5'
|
||||
<samp class="prompt">>>> </samp>print convertedtitle <img id="kgp.unicode.6.5" src="images/callouts/5.png" alt="5" border="0" width="12" height="12">
|
||||
@@ -8724,7 +8724,7 @@ in Python. If your <acronym>XML</acronym> documents are all 7-bit <acronym>ASCI
|
||||
<p>0</p>
|
||||
<p>1</p>
|
||||
</ref></samp>
|
||||
<samp> class="prompt">>>> </samp>print reflist[1].toxml()
|
||||
<samp class="prompt">>>> </samp>print reflist[1].toxml()
|
||||
<samp class="computeroutput"><ref id="byte">
|
||||
<p><xref id="bit"/><xref id="bit"/><xref id="bit"/><xref id="bit"/>\
|
||||
<xref id="bit"/><xref id="bit"/><xref id="bit"/><xref id="bit"/></p>
|
||||
@@ -8747,7 +8747,7 @@ in Python. If your <acronym>XML</acronym> documents are all 7-bit <acronym>ASCI
|
||||
<p>0</p>
|
||||
<p>1</p>
|
||||
</ref></samp>
|
||||
<samp> class="prompt">>>> </samp>plist = firstref.getElementsByTagName("p") <img id="kgp.search.2.2" src="images/callouts/2.png" alt="2" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>plist = firstref.getElementsByTagName("p") <img id="kgp.search.2.2" src="images/callouts/2.png" alt="2" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>plist
|
||||
[<DOM Element: p at 136140116>, <DOM Element: p at 136142172>]
|
||||
<samp class="prompt">>>> </samp>print plist[0].toxml() <img id="kgp.search.2.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12">
|
||||
@@ -8832,7 +8832,7 @@ in Python. If your <acronym>XML</acronym> documents are all 7-bit <acronym>ASCI
|
||||
<p>0</p>
|
||||
<p>1</p>
|
||||
</ref></samp>
|
||||
<samp> class="prompt">>>> </samp>bitref.attributes <img id="kgp.attributes.1.1" src="images/callouts/1.png" alt="1" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>bitref.attributes <img id="kgp.attributes.1.1" src="images/callouts/1.png" alt="1" border="0" width="12" height="12">
|
||||
<xml.dom.minidom.NamedNodeMap instance at 0x81e0c9c>
|
||||
<samp class="prompt">>>> </samp>bitref.attributes.keys() <img id="kgp.attributes.1.2" src="images/callouts/2.png" alt="2" border="0" width="12" height="12"> <img id="kgp.attributes.1.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12">
|
||||
[u'id']
|
||||
@@ -9213,7 +9213,7 @@ with a window-based Python <acronym>IDE</acronym>, <code class="literal">stdout<
|
||||
<samp class="computeroutput">Dive in
|
||||
Dive in
|
||||
Dive in</samp>
|
||||
<samp> class="prompt">>>> </samp>import sys
|
||||
<samp class="prompt">>>> </samp>import sys
|
||||
<samp class="prompt">>>> </samp>for i in range(3):
|
||||
<samp class="prompt">... </samp>sys.stdout.write('Dive in') <img id="kgp.stdio.1.2" src="images/callouts/2.png" alt="2" border="0" width="12" height="12">
|
||||
Dive inDive inDive in
|
||||
@@ -9385,7 +9385,7 @@ one program's output to the next program's input.</p>
|
||||
<xref id="bit"/><xref id="bit"/><xref id="bit"/><xref id="bit"/></p>
|
||||
</ref>
|
||||
</grammar></samp>
|
||||
<samp> class="prompt">[you@localhost kgp]$ </samp>cat binary.xml | python kgp.py -g - <img id="kgp.stdio.4.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12"> <img id="kgp.stdio.4.4" src="images/callouts/4.png" alt="4" border="0" width="12" height="12">
|
||||
<samp class="prompt">[you@localhost kgp]$ </samp>cat binary.xml | python kgp.py -g - <img id="kgp.stdio.4.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12"> <img id="kgp.stdio.4.4" src="images/callouts/4.png" alt="4" border="0" width="12" height="12">
|
||||
10110001</pre><div class="calloutlist">
|
||||
<table border="0" summary="Callout list">
|
||||
<tr>
|
||||
@@ -9681,10 +9681,10 @@ argecho.py
|
||||
<samp class="computeroutput">argecho.py
|
||||
abc
|
||||
def</samp>
|
||||
<samp> class="prompt">[you@localhost py]$ </samp>python argecho.py --help <img id="kgp.commandline.1.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12">
|
||||
<samp class="prompt">[you@localhost py]$ </samp>python argecho.py --help <img id="kgp.commandline.1.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12">
|
||||
<samp class="computeroutput">argecho.py
|
||||
--help</samp>
|
||||
<samp> class="prompt">[you@localhost py]$ </samp>python argecho.py -m kant.xml <img id="kgp.commandline.1.4" src="images/callouts/4.png" alt="4" border="0" width="12" height="12">
|
||||
<samp class="prompt">[you@localhost py]$ </samp>python argecho.py -m kant.xml <img id="kgp.commandline.1.4" src="images/callouts/4.png" alt="4" border="0" width="12" height="12">
|
||||
<samp class="computeroutput">argecho.py
|
||||
-m
|
||||
kant.xml</span></pre><div class="calloutlist">
|
||||
@@ -10414,7 +10414,7 @@ turn it off by setting <code class="literal">httplib.HTTPConnection.debuglevel =
|
||||
'content-length': '15955',
|
||||
'accept-ranges': 'bytes',
|
||||
'connection': 'close'}</samp>
|
||||
<samp> class="prompt">>>> </samp>request.add_header('If-Modified-Since',
|
||||
<samp class="prompt">>>> </samp>request.add_header('If-Modified-Since',
|
||||
<samp class="prompt">... </samp>firstdatastream.headers.get('Last-Modified')) <img id="oa.etags.1.2" src="images/callouts/2.png" alt="2" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>seconddatastream = opener.open(request) <img id="oa.etags.1.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12">
|
||||
<samp class="traceback">Traceback (most recent call last):
|
||||
@@ -10556,7 +10556,7 @@ class DefaultErrorHandler(urllib2.HTTPDefaultErrorHandler): <img id="oa.etags
|
||||
<title mode="escaped">dive into mark</title>
|
||||
<link rel="alternate" type="text/html" href="http://diveintomark.org/"/>
|
||||
<-- rest of feed omitted for brevity --></samp>
|
||||
<samp> class="prompt">>>> </samp>request.add_header('If-None-Match',
|
||||
<samp class="prompt">>>> </samp>request.add_header('If-None-Match',
|
||||
<samp class="prompt">... </samp>firstdatastream.headers.get('ETag')) <img id="oa.etags.4.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>seconddatastream = opener.open(request)
|
||||
<samp class="prompt">>>> </samp>seconddatastream.status <img id="oa.etags.4.4" src="images/callouts/4.png" alt="4" border="0" width="12" height="12">
|
||||
@@ -10646,7 +10646,7 @@ header: Accept-Ranges: bytes
|
||||
header: Content-Length: 15955
|
||||
header: Connection: close
|
||||
header: Content-Type: application/atom+xml</samp>
|
||||
<samp> class="prompt">>>> </samp>f.url <img id="oa.redirect.1.5" src="images/callouts/6.png" alt="6" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>f.url <img id="oa.redirect.1.5" src="images/callouts/6.png" alt="6" border="0" width="12" height="12">
|
||||
'http://diveintomark.org/xml/atom.xml'
|
||||
<samp class="prompt">>>> </samp>f.headers.dict
|
||||
<samp class="computeroutput">{'content-length': '15955',
|
||||
@@ -10657,7 +10657,7 @@ header: Content-Type: application/atom+xml</samp>
|
||||
'etag': '"e842a-3e53-55d97640"',
|
||||
'date': 'Thu, 15 Apr 2004 22:06:25 GMT',
|
||||
'content-type': 'application/atom+xml'}</samp>
|
||||
<samp> class="prompt">>>> </samp>f.status
|
||||
<samp class="prompt">>>> </samp>f.status
|
||||
<samp class="traceback">Traceback (most recent call last):
|
||||
File "<stdin>", line 1, in ?
|
||||
AttributeError: addinfourl instance has no attribute 'status'</span>
|
||||
@@ -10786,7 +10786,7 @@ header: Content-Length: 15955
|
||||
header: Connection: close
|
||||
header: Content-Type: application/atom+xml
|
||||
</samp>
|
||||
<samp> class="prompt">>>> </samp>f.status <img id="oa.redirect.3.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>f.status <img id="oa.redirect.3.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12">
|
||||
301
|
||||
<samp class="prompt">>>> </samp>f.url
|
||||
'http://diveintomark.org/xml/atom.xml'
|
||||
@@ -10848,7 +10848,7 @@ header: Accept-Ranges: bytes
|
||||
header: Content-Length: 15955
|
||||
header: Connection: close
|
||||
header: Content-Type: application/atom+xml</samp>
|
||||
<samp> class="prompt">>>> </samp>f.status <img id="oa.redirect.4.4" src="images/callouts/4.png" alt="4" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>f.status <img id="oa.redirect.4.4" src="images/callouts/4.png" alt="4" border="0" width="12" height="12">
|
||||
302
|
||||
<samp class="prompt">>>> </samp>f.url
|
||||
http://diveintomark.org/xml/atom.xml
|
||||
@@ -10963,7 +10963,7 @@ header: Content-Type: application/atom+xml</span>
|
||||
<title mode="escaped">dive into mark</title>
|
||||
<link rel="alternate" type="text/html" href="http://diveintomark.org/"/>
|
||||
<-- rest of feed omitted for brevity --></samp>
|
||||
<samp> class="prompt">>>> </samp>len(data)
|
||||
<samp class="prompt">>>> </samp>len(data)
|
||||
15955
|
||||
</pre><div class="calloutlist">
|
||||
<table border="0" summary="Callout list">
|
||||
@@ -11186,7 +11186,7 @@ def fetch(source, etag=None, last_modified=None, agent=USER_AGENT):
|
||||
'data': '<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<feed version="0.3"
|
||||
<-- rest of data omitted for brevity -->'}</samp>
|
||||
<samp> class="prompt">>>> </samp>if params['status'] == 301:<img id="oa.alltogether.3.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>if params['status'] == 301:<img id="oa.alltogether.3.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12">
|
||||
<samp class="prompt">... </samp>url = params['url']
|
||||
<samp class="prompt">>>> </samp>newparams = openanything.fetch(
|
||||
<samp class="prompt">... </samp>url, params['etag'], params['lastmodified'], useragent) <img id="oa.alltogether.3.4" src="images/callouts/4.png" alt="4" border="0" width="12" height="12">
|
||||
@@ -11526,7 +11526,7 @@ region.</p>
|
||||
</SOAP-ENV:Envelope>
|
||||
************************************************************************
|
||||
</samp>
|
||||
<samp> class="prompt">>>> </samp>temperature
|
||||
<samp class="prompt">>>> </samp>temperature
|
||||
80.0
|
||||
</pre><div class="calloutlist">
|
||||
<table border="0" summary="Callout list">
|
||||
@@ -11784,7 +11784,7 @@ u'return'
|
||||
</SOAP-ENV:Envelope>
|
||||
************************************************************************
|
||||
</samp>
|
||||
<samp> class="prompt">>>> </samp>temperature
|
||||
<samp class="prompt">>>> </samp>temperature
|
||||
66.0
|
||||
</pre><div class="calloutlist">
|
||||
<table border="0" summary="Callout list">
|
||||
@@ -11949,7 +11949,7 @@ and you can access it programmatically too.</p>
|
||||
{'fullViewableName':
|
||||
'Top/Arts/Literature/World_Literature/American/19th_Century/Twain,_Mark',
|
||||
'specialEncoding': ''}]</samp>
|
||||
<samp> class="prompt">>>> </samp>results.directoryCategories[0].fullViewableName
|
||||
<samp class="prompt">>>> </samp>results.directoryCategories[0].fullViewableName
|
||||
'Top/Arts/Literature/World_Literature/American/19th_Century/Twain,_Mark'
|
||||
</pre><div class="calloutlist">
|
||||
<table border="0" summary="Callout list">
|
||||
@@ -13295,7 +13295,7 @@ def fromRoman(s):
|
||||
File "roman3.py", line 27, in toRoman
|
||||
raise OutOfRangeError, "number out of range (must be 1..3999)"
|
||||
OutOfRangeError: number out of range (must be 1..3999)</samp>
|
||||
<samp> class="prompt">>>> </samp>roman3.toRoman(1.5)
|
||||
<samp class="prompt">>>> </samp>roman3.toRoman(1.5)
|
||||
<samp class="traceback">Traceback (most recent call last):
|
||||
File "<interactive input>", line 1, in ?
|
||||
File "roman3.py", line 29, in toRoman
|
||||
@@ -14828,11 +14828,11 @@ print 'full path =', os.path.abspath(pathname) <img id="regression.path.1.3" src
|
||||
<samp class="computeroutput">sys.argv[0] = /home/you/diveintopython3/common/py/fullpath.py
|
||||
path = /home/you/diveintopython3/common/py
|
||||
full path = /home/you/diveintopython3/common/py</samp>
|
||||
<samp> class="prompt">[you@localhost diveintopython3]$ </samp>python common/py/fullpath.py <img id="regression.path.3.2" src="images/callouts/2.png" alt="2" border="0" width="12" height="12">
|
||||
<samp class="prompt">[you@localhost diveintopython3]$ </samp>python common/py/fullpath.py <img id="regression.path.3.2" src="images/callouts/2.png" alt="2" border="0" width="12" height="12">
|
||||
<samp class="computeroutput">sys.argv[0] = common/py/fullpath.py
|
||||
path = common/py
|
||||
full path = /home/you/diveintopython3/common/py</samp>
|
||||
<samp> class="prompt">[you@localhost diveintopython3]$ </samp>cd common/py
|
||||
<samp class="prompt">[you@localhost diveintopython3]$ </samp>cd common/py
|
||||
<samp class="prompt">[you@localhost py]$ </samp>python fullpath.py <img id="regression.path.3.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12">
|
||||
<samp class="computeroutput">sys.argv[0] = fullpath.py
|
||||
path =
|
||||
@@ -15164,7 +15164,7 @@ to doesn't need to match the module name, either. You could import a series of
|
||||
<module 'os' from 'c:\Python22\lib\os.pyc'>,
|
||||
<module 're' from 'c:\Python22\lib\re.pyc'>,
|
||||
<module 'unittest' from 'c:\Python22\lib\unittest.pyc'>]</samp>
|
||||
<samp> class="prompt">>>> </samp>modules[0].version <img id="regression.import.3.4" src="images/callouts/4.png" alt="4" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>modules[0].version <img id="regression.import.3.4" src="images/callouts/4.png" alt="4" border="0" width="12" height="12">
|
||||
'2.2.2 (#37, Nov 26 2002, 10:24:37) [MSC 32 bit (Intel)]'
|
||||
<samp class="prompt">>>> </samp>import sys
|
||||
<samp class="prompt">>>> </samp>sys.version
|
||||
@@ -15318,7 +15318,7 @@ return unittest.TestSuite(map(load, modules))
|
||||
<module 'odbchelpertest' from 'odbchelpertest.py'>,
|
||||
<module 'pluraltest' from 'pluraltest.py'>,
|
||||
<module 'romantest' from 'romantest.py'>]</samp>
|
||||
<samp> class="prompt">>>> </samp>modules[-1] <img id="regression.alltogether.4.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>modules[-1] <img id="regression.alltogether.4.3" src="images/callouts/3.png" alt="3" border="0" width="12" height="12">
|
||||
<module 'romantest' from 'romantest.py'>
|
||||
</pre><div class="calloutlist">
|
||||
<table border="0" summary="Callout list">
|
||||
@@ -15356,7 +15356,7 @@ return unittest.TestSuite(map(load, modules))
|
||||
...
|
||||
]
|
||||
]</samp>
|
||||
<samp> class="prompt">>>> </samp>unittest.TestSuite(map(load, modules)) <img id="regression.alltogether.5.2" src="images/callouts/2.png" alt="2" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>unittest.TestSuite(map(load, modules)) <img id="regression.alltogether.5.2" src="images/callouts/2.png" alt="2" border="0" width="12" height="12">
|
||||
</pre><div class="calloutlist">
|
||||
<table border="0" summary="Callout list">
|
||||
<tr>
|
||||
@@ -16023,10 +16023,10 @@ def plural(noun, language='en'):
|
||||
<samp class="prompt">>>> </samp>counter.next() <img id="plural.stage6.2.4" src="images/callouts/4.png" alt="4" border="0" width="12" height="12">
|
||||
<samp class="computeroutput">entering make_counter
|
||||
2</samp>
|
||||
<samp> class="prompt">>>> </samp>counter.next() <img id="plural.stage6.2.5" src="images/callouts/5.png" alt="5" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>counter.next() <img id="plural.stage6.2.5" src="images/callouts/5.png" alt="5" border="0" width="12" height="12">
|
||||
<samp class="computeroutput">incrementing x
|
||||
3</samp>
|
||||
<samp> class="prompt">>>> </samp>counter.next() <img id="plural.stage6.2.6" src="images/callouts/6.png" alt="6" border="0" width="12" height="12">
|
||||
<samp class="prompt">>>> </samp>counter.next() <img id="plural.stage6.2.6" src="images/callouts/6.png" alt="6" border="0" width="12" height="12">
|
||||
<samp class="computeroutput">incrementing x
|
||||
4</span>
|
||||
</pre><div class="calloutlist">
|
||||
|
||||
Reference in New Issue
Block a user