Skip to content

Commit dadd444

Browse files
committed
Some tweakage of the book
1 parent 1e149a8 commit dadd444

16 files changed

+1092
-36
lines changed

book/01-intro.mkd

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ assistants" who can take care of many things on our behalf. The hardware
1919
in our current-day computers is essentially built to continuously ask us
2020
the question, "What would you like me to do next?"
2121

22-
![image](figs2/pda)
22+
![Personal Digital Assistant](../images/pda)
2323

2424
Programmers add an operating system and a set of applications to the
2525
hardware and we end up with a Personal Digital Assistant that is quite

book/07-files.mkd

+4-4
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ stored. When you open a file, you are asking the operating system to
4949
find the file by name and make sure the file exists. In this example, we
5050
open the file `mbox.txt`, which should be stored in the same
5151
folder that you are in when you start Python. You can download this file
52-
from [www.py4inf.com/code/mbox.txt](www.py4inf.com/code/mbox.txt)
52+
from [www.pythonlearn.com/code/mbox.txt](www.pythonlearn.com/code/mbox.txt)
5353

5454
>>> fhand = open('mbox.txt')
5555
>>> print(fhand)
@@ -95,9 +95,9 @@ individuals in an open source project development team:
9595
`...`
9696

9797
The entire file of mail interactions is available from
98-
[www.py4inf.com/code/mbox.txt](www.py4inf.com/code/mbox.txt) and a
98+
[www.pythonlearn.com/code/mbox.txt](www.pythonlearn.com/code/mbox.txt) and a
9999
shortened version of the file is available from
100-
[www.py4inf.com/code/mbox-short.txt](www.py4inf.com/code/mbox-short.txt).
100+
[www.pythonlearn.com/code/mbox-short.txt](www.pythonlearn.com/code/mbox-short.txt).
101101
These files are in a standard format for a file containing multiple mail
102102
messages. The lines which start with "From " separate the messages and
103103
the lines which start with "From:" are part of the messages. For more
@@ -592,7 +592,7 @@ program will look as follows:
592592
SAT, 05 JAN 2008 09:14:16 -0500
593593

594594
You can download the file from
595-
[www.py4inf.com/code/mbox-short.txt](www.py4inf.com/code/mbox-short.txt)
595+
[www.pythonlearn.com/code/mbox-short.txt](www.pythonlearn.com/code/mbox-short.txt)
596596

597597
Exercise 2: Write a program to prompt for a file name, and then read
598598
through the file and look for lines of the form:

book/08-lists.mkd

+1-1
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ Exercises
10151015
---------
10161016

10171017
Exercise 4: Download a copy of the file from
1018-
[www.py4inf.com/code/romeo.txt](www.py4inf.com/code/romeo.txt)
1018+
[www.pythonlearn.com/code/romeo.txt](www.pythonlearn.com/code/romeo.txt)
10191019

10201020
\index{Romeo and Juliet}
10211021

book/09-dictionaries.mkd

+1-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ word on every line of the input file.
293293

294294
When we run the program, we see a raw dump of all of the counts in
295295
unsorted hash order. (the `romeo.txt` file is available at
296-
[www.py4inf.com/code/romeo.txt](www.py4inf.com/code/romeo.txt))
296+
[www.pythonlearn.com/code/romeo.txt](www.pythonlearn.com/code/romeo.txt))
297297

298298
python count1.py
299299
Enter the file name: romeo.txt

book/12-network.mkd

+18-18
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ This is a long and complex 176-page document with a lot of detail. If
4545
you find it interesting, feel free to read it all. But if you take a
4646
look around page 36 of RFC2616 you will find the syntax for the GET
4747
request. To request a document from a web server, we make a connection
48-
to the `www.py4inf.com` server on port 80, and then send a
48+
to the `www.pythonlearn.com` server on port 80, and then send a
4949
line of the form
5050

51-
`GET http://www.py4inf.com/code/romeo.txt HTTP/1.0 `
51+
`GET http://www.pythonlearn.com/code/romeo.txt HTTP/1.0 `
5252

5353
where the second parameter is the web page we are requesting, and then
5454
we also send a blank line. The web server will respond with some header
@@ -66,8 +66,8 @@ display what the server sends back.
6666
import socket
6767

6868
mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
69-
mysock.connect(('www.py4inf.com', 80))
70-
mysock.send('GET http://www.py4inf.com/code/romeo.txt HTTP/1.0\n\n')
69+
mysock.connect(('www.pythonlearn.com', 80))
70+
mysock.send('GET http://www.pythonlearn.com/code/romeo.txt HTTP/1.0\n\n')
7171

7272
while True:
7373
data = mysock.recv(512)
@@ -78,7 +78,7 @@ display what the server sends back.
7878
mysock.close()
7979

8080
First the program makes a connection to port 80 on the server
81-
[www.py4inf.com](www.py4inf.com). Since our program is playing the role
81+
[www.pythonlearn.com](www.pythonlearn.com). Since our program is playing the role
8282
of the "web browser", the HTTP protocol says we must send the GET
8383
command followed by a blank line.
8484

@@ -142,8 +142,8 @@ image data to a file as follows:
142142
import time
143143

144144
mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
145-
mysock.connect(('www.py4inf.com', 80))
146-
mysock.send('GET http://www.py4inf.com/cover.jpg HTTP/1.0\n\n')
145+
mysock.connect(('www.pythonlearn.com', 80))
146+
mysock.send('GET http://www.pythonlearn.com/cover.jpg HTTP/1.0\n\n')
147147

148148
count = 0
149149
picture = "";
@@ -268,7 +268,7 @@ using `urllib` is as follows:
268268

269269
import urllib.request, urllib.parse, urllib.error
270270

271-
fhand = urllib.request.urlopen('http://www.py4inf.com/code/romeo.txt')
271+
fhand = urllib.request.urlopen('http://www.pythonlearn.com/code/romeo.txt')
272272
for line in fhand:
273273
print(line.strip())
274274

@@ -292,7 +292,7 @@ file as follows:
292292
import urllib.request, urllib.parse, urllib.error
293293

294294
counts = dict()
295-
fhand = urllib.request.urlopen('http://www.py4inf.com/code/romeo.txt')
295+
fhand = urllib.request.urlopen('http://www.pythonlearn.com/code/romeo.txt')
296296
for line in fhand:
297297
words = line.split()
298298
for word in words:
@@ -381,12 +381,12 @@ When we run the program, we get the following output:
381381
http://www.dr-chuck.com/page2.htm
382382

383383
python urlregex.py
384-
Enter - http://www.py4inf.com/book.htm
384+
Enter - http://www.pythonlearn.com/book.htm
385385
http://www.greenteapress.com/thinkpython/thinkpython.html
386386
http://allendowney.com/
387-
http://www.py4inf.com/code
387+
http://www.pythonlearn.com/code
388388
http://www.lib.umich.edu/espresso-book-machine
389-
http://www.py4inf.com/py4inf-slides.zip
389+
http://www.pythonlearn.com/py4inf-slides.zip
390390

391391
Regular expressions work very nicely when your HTML is well formatted
392392
and predictable. But since there are a lot of "broken" HTML pages out
@@ -453,12 +453,12 @@ When the program runs it looks as follows:
453453
http://www.dr-chuck.com/page2.htm
454454

455455
python urllinks.py
456-
Enter - http://www.py4inf.com/book.htm
456+
Enter - http://www.pythonlearn.com/book.htm
457457
http://www.greenteapress.com/thinkpython/thinkpython.html
458458
http://allendowney.com/
459459
http://www.si502.com/
460460
http://www.lib.umich.edu/espresso-book-machine
461-
http://www.py4inf.com/code
461+
http://www.pythonlearn.com/code
462462
http://www.pythonlearn.com/
463463

464464
You can use BeautifulSoup to pull out various parts of each tag as
@@ -509,7 +509,7 @@ entire contents of the document into a string variable
509509
(`img`) then write that information to a local file as
510510
follows:
511511

512-
img = urllib.request.urlopen('http://www.py4inf.com/cover.jpg').read()
512+
img = urllib.request.urlopen('http://www.pythonlearn.com/cover.jpg').read()
513513
fhand = open('cover.jpg', 'w')
514514
fhand.write(img)
515515
fhand.close()
@@ -529,7 +529,7 @@ using up all of the memory you have in your computer.
529529

530530
import urllib.request, urllib.parse, urllib.error
531531

532-
img = urllib.request.urlopen('http://www.py4inf.com/cover.jpg')
532+
img = urllib.request.urlopen('http://www.pythonlearn.com/cover.jpg')
533533
fhand = open('cover.jpg', 'w')
534534
size = 0
535535
while True:
@@ -556,11 +556,11 @@ follows:
556556

557557
\index{curl}
558558

559-
curl -O http://www.py4inf.com/cover.jpg
559+
curl -O http://www.pythonlearn.com/cover.jpg
560560

561561
The command `curl` is short for "copy URL" and so these two
562562
examples are cleverly named `curl1.py` and
563-
`curl2.py` on [www.py4inf.com/code](www.py4inf.com/code) as
563+
`curl2.py` on [www.pythonlearn.com/code](www.pythonlearn.com/code) as
564564
they implement similar functionality to the `curl` command.
565565
There is also a `curl3.py` sample program that does this task
566566
a little more effectively, in case you actually want to use this pattern

book/13-web.mkd

+5-5
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,8 @@ been removed):
402402
Enter location:
403403

404404
You can download
405-
[www.py4inf.com/code/geojson.py](www.py4inf.com/code/geojson.py) and
406-
[www.py4inf.com/code/geoxml.py](www.py4inf.com/code/geoxml.py) to
405+
[www.pythonlearn.com/code/geojson.py](www.pythonlearn.com/code/geojson.py) and
406+
[www.pythonlearn.com/code/geoxml.py](www.pythonlearn.com/code/geoxml.py) to
407407
explore the JSON and XML variants of the Google geocoding API.
408408

409409
Security and API usage
@@ -441,7 +441,7 @@ libraries.
441441
For this next sample program we will download the files
442442
*twurl.py*, *hidden.py*,
443443
*oauth.py*, and *twitter1.py* from
444-
[www.py4inf.com/code](www.py4inf.com/code) and put them all in a folder
444+
[www.pythonlearn.com/code](www.pythonlearn.com/code) and put them all in a folder
445445
on your computer.
446446

447447
To make use of these programs you will need to have a Twitter account,
@@ -673,8 +673,8 @@ Exercises
673673
---------
674674

675675
Exercise 1: Change either the
676-
[www.py4inf.com/code/geojson.py](www.py4inf.com/code/geojson.py) or
677-
[www.py4inf.com/code/geoxml.py](www.py4inf.com/code/geoxml.py) to print
676+
[www.pythonlearn.com/code/geojson.py](www.pythonlearn.com/code/geojson.py) or
677+
[www.pythonlearn.com/code/geoxml.py](www.pythonlearn.com/code/geoxml.py) to print
678678
out the two-character country code from the retrieved data. Add error
679679
checking so your program does not traceback if the country code is not
680680
there. Once you have it working, search for "Atlantic Ocean" and make

book/15-viz.mkd

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ the data on a Google map.
2626

2727
To get started, download the application from:
2828

29-
[www.py4inf.com/code/geodata.zip](www.py4inf.com/code/geodata.zip)
29+
[www.pythonlearn.com/code/geodata.zip](www.pythonlearn.com/code/geodata.zip)
3030

3131
The first problem to solve is that the free Google geocoding API is
3232
rate-limited to a certain number of requests per day. If you have a lot
@@ -144,7 +144,7 @@ visualization output.
144144

145145
You can download and extract this application from:
146146

147-
[www.py4inf.com/code/pagerank.zip](www.py4inf.com/code/pagerank.zip)
147+
[www.pythonlearn.com/code/pagerank.zip](www.pythonlearn.com/code/pagerank.zip)
148148

149149
![image](figs2/pagerank)
150150

@@ -284,7 +284,7 @@ far and pull down nearly a gigabyte of data and visualize it.
284284

285285
You can download this application from:
286286

287-
[www.py4inf.com/code/gmane.zip](www.py4inf.com/code/gmane.zip)
287+
[www.pythonlearn.com/code/gmane.zip](www.pythonlearn.com/code/gmane.zip)
288288

289289
We will be using data from a free email list archiving service called
290290
[www.gmane.org](www.gmane.org). This service is very popular with open

book/AA-windows.mkd

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,4 @@ expand tab characters to be four spaces. This will save you lots of
8989
effort looking for indentation errors.
9090

9191
You can also find further information on editing and running Python
92-
programs at [www.py4inf.com](www.py4inf.com).
92+
programs at [www.pythonlearn.com](www.pythonlearn.com).

book/AB-apple.mkd

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,4 @@ expand tab characters to be four spaces. It will save you lots of effort
7575
looking for indentation errors.
7676

7777
You can also find further information on editing and running Python
78-
programs at [www.py4inf.com](www.py4inf.com).
78+
programs at [www.pythonlearn.com](www.pythonlearn.com).

book/README.md

+15-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,23 @@ Python for Everybody
33

44
Welcome to the under-construction book "Python for Everybody".
55

6-
If you want to contribute, feel free to for the pythonlearn
6+
While this book is under construction, it is copyright, all rights reserved
7+
Charles R. Severance. Once the book is in better shape I will move it back
8+
to Creative Commons.
9+
10+
If you want to contribute, feel free to fork the pythonlearn
711
repository and send me pull requests. We can also use the
812
issue tracker.
913

14+
Tasks to do:
15+
16+
* Go through and fix all the code sequences
17+
18+
* Find, fix and remove all the Python 3.0 does this differend footnotes
19+
20+
* Make a new cover
21+
22+
* Redraw all figures in OmniGraffle
23+
1024
/Chuck
1125

book/mgrep.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
for fn in *.mkd; do
3+
echo "the next file is $fn"
4+
x=`basename $fn .mkd`
5+
echo $x
6+
sed 's/www.py4inf.com/www.pythonlearn.com/'g < $x.mkd > /tmp/$x.mkd
7+
cp /tmp/$x.mkd $x.mkd
8+
9+
done

book/x.epub

1.37 KB
Binary file not shown.

book/x.pdf

8.11 KB
Binary file not shown.

figures/pda.graffle

1.93 KB
Binary file not shown.

0 commit comments

Comments
 (0)