mirror of
https://github.com/kennethreitz/dive-into-python3.git
synced 2026-06-05 15:00:18 +00:00
cycle through image servers
This commit is contained in:
@@ -9,12 +9,8 @@
|
||||
of other platforms you've probably never even heard of.
|
||||
<p>What's more, Python programs written on one platform can, with a little care, run on <em>any</em> supported platform. For instance, I regularly develop Python programs on Windows and later deploy them on Linux.
|
||||
<p>So back to the question that started this section, “Which Python is right for you?” The answer is whichever one runs on the computer you already have.
|
||||
|
||||
<h2 id="install.windows">1.2. Python on Windows</h2>
|
||||
<p>On Windows, you have a couple choices for installing Python.
|
||||
<p>ActiveState makes a Windows installer for Python called ActivePython, which includes a complete version of Python, an <abbr>IDE</abbr> with a Python-aware code editor, plus some Windows extensions for Python that allow complete access to Windows-specific services, <abbr>API</abbr>s, and the Windows Registry.
|
||||
<p>ActivePython is freely downloadable, although it is not open source. It is the <abbr>IDE</abbr> I used to learn Python, and I recommend you try it unless you have a specific reason not to. One such reason might be that ActiveState is generally
|
||||
several months behind in updating their ActivePython installer when new version of Python are released. If you absolutely need the latest version of Python and ActivePython is still a version behind as you read this, you'll want to use the second option for installing Python on Windows.
|
||||
<p>The second option is the “official” Python installer, distributed by the people who develop Python itself. It is freely downloadable and open source, and it is always current with the latest version of Python.
|
||||
<div class=procedure>
|
||||
<h3>Procedure 1.1. Option 1: Installing ActivePython</h3>
|
||||
<p>Here is the procedure for installing ActivePython:
|
||||
|
||||
+25
-2
@@ -16,14 +16,24 @@ body{counter-reset:h1 0}
|
||||
<p id=level>Difficulty level: <span class=u title=novice>♦♢♢♢♢</span>
|
||||
<h1>Installing Python</h1>
|
||||
<blockquote class=q>
|
||||
<p><span class=u>❝</span> FIXME <span class=u>❞</span><br>— FIXME
|
||||
<p><span class=u>❝</span> <i lang=la>Tempora mutantur nos et mutamur in illis.</i> (Times change, and we change with them.) <span class=u>❞</span><br>— ancient Roman proverb
|
||||
</blockquote>
|
||||
<p id=toc>
|
||||
<h2 id=divingin>Diving in</h2>
|
||||
<p class=f>FIXME
|
||||
<p class=f>Welcome to Python 3. Let's dive in. In this chapter, you'll install the version of Python 3 that's right for you.
|
||||
|
||||
<h2 id=which>Which Python Is Right For You?</h2>
|
||||
|
||||
<p>The first thing you need to do with Python is install it. Or do you?
|
||||
|
||||
<p>If you're using an account on a hosted server, your ISP may have already installed Python 3. Most popular GNU/Linux distributions come with Python 2 in the default installation; a small but growing number of distributions also include Python 3. (As you’ll see in this chapter, you can have more than one version of Python installed on your computer.) Mac OS X includes a command-line version of Python 2, although you'll probably want to install a version that includes a more Mac-like graphical interface.
|
||||
<p>Windows does not come with any version of Python, but don’t despair! There are several ways to point-and-click your way to Python on Windows.
|
||||
<p>What's more, Python programs written on one platform can run on <em>any</em> supported platform. For instance, I regularly develop Python programs on Windows and later deploy them on Linux.
|
||||
<p>So back to the question that started this section, “Which Python is right for you?” The answer is whichever one runs on the computer you already have.
|
||||
|
||||
<h2 id=windows>Installing on Microsoft Windows</h2>
|
||||
|
||||
<p>FIXME
|
||||
<p><img src=i/win-install-0-security-warning.png width=409 height=309 alt='[Windows dialog: open file security warning]'>
|
||||
<p><img src=i/win-install-1-all-users-or-just-me.png width=499 height=432 alt='[Python installer: select whether to install Python 3.1 for all users of this computer]'>
|
||||
<p><img src=i/win-install-2-destination-directory.png width=499 height=432 alt='[Python installer: select destination directory]'>
|
||||
@@ -36,6 +46,7 @@ body{counter-reset:h1 0}
|
||||
|
||||
<h2 id=macosx>Installing on Mac OS X</h2>
|
||||
|
||||
<p>FIXME
|
||||
<p><img src=i/mac-install-0-dmg-contents.png width=752 height=438 alt='[contents of Python installer disk image]'>
|
||||
<p><img src=i/mac-install-1-welcome.png width=622 height=442 alt='[Python installer: welcome screen]'>
|
||||
<p><img src=i/mac-install-2-information.png width=622 height=442 alt='[Python installer: information about supported architectures, disk space, and acceptable destination folders]'>
|
||||
@@ -52,6 +63,7 @@ body{counter-reset:h1 0}
|
||||
|
||||
<h2 id=ubuntu>Installing on Ubuntu Linux</h2>
|
||||
|
||||
<p>FIXME
|
||||
<p><img src=i/ubu-install-0-add-remove-programs.png width=920 height=473 alt='[Add/Remove: Canonical-maintained applications]'>
|
||||
<p><img src=i/ubu-install-1-all-open-source-applications.png width=920 height=473 alt='[Add/Remove: all open source applications]'>
|
||||
<p><img src=i/ubu-install-2-search-python-3.png width=920 height=473 alt='[Add/Remove: search for Python 3]'>
|
||||
@@ -68,6 +80,17 @@ body{counter-reset:h1 0}
|
||||
|
||||
<p>FIXME
|
||||
|
||||
<h2 id=editors>Python Editors and IDEs</h2>
|
||||
|
||||
<p>FIXME
|
||||
<pre>
|
||||
http://wiki.python.org/moin/PythonEditors
|
||||
http://wiki.python.org/moin/IntegratedDevelopmentEnvironments
|
||||
http://pydev.sourceforge.net/
|
||||
http://www.activestate.com/komodo/
|
||||
http://www.activestate.com/activepython/
|
||||
</pre>
|
||||
|
||||
<p class=v><a href=whats-new.html rel=prev title='back to “What’s New In Dive Into Python 3”'><span class=u>☜</span></a> <a href=your-first-python-program.html rel=next title='onward to “Your First Python Program”'><span class=u>☞</span></a>
|
||||
|
||||
<p class=c>© 2001–9 <a href=about.html>Mark Pilgrim</a>
|
||||
|
||||
@@ -74,5 +74,6 @@ chmod 644 build/*.html build/*.css build/examples/*.py build/examples/*.txt buil
|
||||
|
||||
# ship it!
|
||||
echo "publishing"
|
||||
rsync -essh -avz build/i/* build/i/.htaccess diveintomark.org:~/web/wearehugh.com/dip3/
|
||||
rsync -essh -avz build/j/$revision.js build/j/html5.js build/j/.htaccess diveintomark.org:~/web/diveintopython3.org/j/
|
||||
rsync -essh -avz build/*.html build/examples build/*.txt build/i diveintomark.org:~/web/diveintopython3.org/
|
||||
rsync -essh -avz build/examples build/*.txt build/*.html diveintomark.org:~/web/diveintopython3.org/
|
||||
|
||||
+13
-1
@@ -1,12 +1,24 @@
|
||||
"""Quick-and-dirty HTML minimizer"""
|
||||
|
||||
import sys, re, html.entities
|
||||
import sys
|
||||
import re
|
||||
import html.entities
|
||||
import itertools
|
||||
|
||||
_SERVERS = ['a.wearehugh.com',
|
||||
'b.wearehugh.com',
|
||||
'c.wearehugh.com',
|
||||
'd.wearehugh.com']
|
||||
available_server = itertools.cycle(_SERVERS)
|
||||
input_file = sys.argv[1]
|
||||
output_file = sys.argv[2]
|
||||
in_pre = False
|
||||
out = open(output_file, 'w', encoding="utf-8") # encoding argument! important!
|
||||
for line in open(input_file, encoding="utf-8").readlines():
|
||||
# round-robin image servers
|
||||
if "<img src=i/" in line:
|
||||
line = line.replace("<img src=i/", "<img src=http://" + next(available_server) + "/dip3/")
|
||||
|
||||
# replace entities with Unicode characters
|
||||
for e in re.findall('&(.+?);', line):
|
||||
if e in ('lt', 'amp', 'quot', 'apos', 'nbsp'):
|
||||
|
||||
Reference in New Issue
Block a user