Mercurial > cpython-lru_cache-weakref
annotate Doc/mac/using.tex @ 38664:7619216bbc19 2.4
Bug #1502728: Correctly link against librt library on HP-UX.
(backport from rev. 46743)
| author | Georg Brandl <georg@python.org> |
|---|---|
| date | Thu, 08 Jun 2006 12:54:16 +0000 |
| parents | 7e7e86f45255 |
| children | 388b7d90bb89 |
| rev | line source |
|---|---|
|
34586
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
1 \chapter{Using Python on a Macintosh \label{using}} |
|
15229
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
2 \sectionauthor{Bob Savage}{bobsavage@mac.com} |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
3 |
|
34586
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
4 Python on a Macintosh running Mac OS X is in principle very similar to |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
5 Python on any other \UNIX platform, but there are a number of additional |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
6 features such as the IDE and the Package Manager that are worth pointing out. |
|
15229
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
7 |
|
34586
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
8 Python on Mac OS 9 or earlier can be quite different from Python on |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
9 Unix or Windows, but is beyond the scope of this manual, as that platform |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
10 is no longer supported, starting with Python 2.4. See |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
11 \url{http://www.cwi.nl/\textasciitilde jack/macpython} for installers |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
12 for the latest 2.3 release for Mac OS 9 and related documentation. |
|
15229
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
13 |
|
34586
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
14 \section{Getting and Installing MacPython \label{getting-OSX}} |
|
28546
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
15 |
|
34586
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
16 Mac OS X 10.3 comes with Python 2.3 pre-installed by Apple. |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
17 This installation does not come with the IDE and other additions, however, |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
18 so to get these you need to install the \program{MacPython for Panther additions} |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
19 from the MacPython website, \url{http://www.cwi.nl/\textasciitilde jack/macpython}. |
|
28546
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
20 |
|
34586
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
21 For MacPython 2.4, or for any MacPython on earlier releases of Mac OS X, |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
22 you need to install a full distribution from the same website. |
|
28546
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
23 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
24 What you get after installing is a number of things: |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
25 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
26 \begin{itemize} |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
27 \item A \file{MacPython-2.3} folder in your \file{Applications} |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
28 folder. In here you find the PythonIDE Integrated Development Environment; |
|
29966
fe499bc7381f
Avoid a 301 permanent redirect.
Fred Drake <fdrake@acm.org>
parents:
28578
diff
changeset
|
29 PythonLauncher, which handles double-clicking Python scripts from |
|
fe499bc7381f
Avoid a 301 permanent redirect.
Fred Drake <fdrake@acm.org>
parents:
28578
diff
changeset
|
30 the Finder; and the Package Manager. |
|
28546
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
31 |
|
29966
fe499bc7381f
Avoid a 301 permanent redirect.
Fred Drake <fdrake@acm.org>
parents:
28578
diff
changeset
|
32 \item A fairly standard \UNIX{} commandline Python interpreter in |
|
fe499bc7381f
Avoid a 301 permanent redirect.
Fred Drake <fdrake@acm.org>
parents:
28578
diff
changeset
|
33 \file{/usr/local/bin/python}, but without the usual |
|
fe499bc7381f
Avoid a 301 permanent redirect.
Fred Drake <fdrake@acm.org>
parents:
28578
diff
changeset
|
34 \file{/usr/local/lib/python}. |
|
28546
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
35 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
36 \item A framework \file{/Library/Frameworks/Python.framework}, where |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
37 all the action really is, but which you usually do not have to be aware of. |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
38 \end{itemize} |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
39 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
40 To uninstall MacPython you can simply remove these three things. |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
41 |
|
34586
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
42 If you use the ``additions'' installer to install on top of an existing |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
43 Apple-Python you will not get the framework and the commandline interpreter, |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
44 as they have been installed by Apple already, in |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
45 \file{/System/Library/Frameworks/Python.framework} and |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
46 \file{/usr/bin/python}, respectively. You should in principle never modify |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
47 or delete these, as they are Apple-controlled and may be used by Apple- or |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
48 third-party software. |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
49 |
|
28546
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
50 PythonIDE contains an Apple Help Viewer book called "MacPython Help" |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
51 which you can access through its help menu. If you are completely new to |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
52 Python you should start reading the IDE introduction in that document. |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
53 |
|
29966
fe499bc7381f
Avoid a 301 permanent redirect.
Fred Drake <fdrake@acm.org>
parents:
28578
diff
changeset
|
54 If you are familiar with Python on other \UNIX{} platforms you should |
|
fe499bc7381f
Avoid a 301 permanent redirect.
Fred Drake <fdrake@acm.org>
parents:
28578
diff
changeset
|
55 read the section on running Python scripts from the \UNIX{} shell. |
|
28546
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
56 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
57 \subsection{How to run a Python script} |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
58 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
59 Your best way to get started with Python on Mac OS X is through the PythonIDE |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
60 integrated development environment, see section \ref{IDE} and use the Help |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
61 menu when the IDE is running. |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
62 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
63 If you want to run Python scripts from the Terminal window command line |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
64 or from the Finder you first need an editor to create your script. |
|
29966
fe499bc7381f
Avoid a 301 permanent redirect.
Fred Drake <fdrake@acm.org>
parents:
28578
diff
changeset
|
65 Mac OS X comes with a number of standard \UNIX{} command line editors, |
|
34586
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
66 \program{vim} and \program{emacs} among them. If you want a more Mac-like |
|
28546
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
67 editor \program{BBEdit} or \program{TextWrangler} from Bare Bones Software |
|
29966
fe499bc7381f
Avoid a 301 permanent redirect.
Fred Drake <fdrake@acm.org>
parents:
28578
diff
changeset
|
68 (see \url{http://www.barebones.com/products/bbedit/index.shtml}) are |
|
34586
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
69 good choices. \program{AppleWorks} or any other |
|
34250
e82d183258f9
Fix mention of TextEdit to state it can save in plaintext.
Brett Cannon <bcannon@gmail.com>
parents:
33647
diff
changeset
|
70 word processor that can save files in ASCII is also a possibility, including |
|
e82d183258f9
Fix mention of TextEdit to state it can save in plaintext.
Brett Cannon <bcannon@gmail.com>
parents:
33647
diff
changeset
|
71 \program{TextEdit} which is included with OS X. |
|
28546
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
72 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
73 To run your script from the Terminal window you must make sure that |
|
34586
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
74 \file{/usr/local/bin} is in your shell search path. |
|
28546
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
75 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
76 To run your script from the Finder you have two options: |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
77 \begin{itemize} |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
78 \item Drag it to \program{PythonLauncher} |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
79 \item Select \program{PythonLauncher} as the default application |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
80 to open your script (or any .py script) through the finder Info window |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
81 and double-click it. |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
82 \end{itemize} |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
83 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
84 PythonLauncher has various preferences to control how your script is launched. |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
85 Option-dragging allows you to change these for one invocation, or use its |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
86 Preferences menu to change things globally. |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
87 |
|
28578
8b49445c0a0e
Moved all the scripting stuff to a separate section, added all the
Jack Jansen <jack.jansen@cwi.nl>
parents:
28546
diff
changeset
|
88 \subsection{Running scripts with a GUI \label{osx-gui-scripts}} |
|
8b49445c0a0e
Moved all the scripting stuff to a separate section, added all the
Jack Jansen <jack.jansen@cwi.nl>
parents:
28546
diff
changeset
|
89 |
|
8b49445c0a0e
Moved all the scripting stuff to a separate section, added all the
Jack Jansen <jack.jansen@cwi.nl>
parents:
28546
diff
changeset
|
90 There is one Mac OS X quirk that you need to be aware of: programs |
|
8b49445c0a0e
Moved all the scripting stuff to a separate section, added all the
Jack Jansen <jack.jansen@cwi.nl>
parents:
28546
diff
changeset
|
91 that talk to the Aqua window manager (in other words, anything that has a GUI) |
|
31188
b2a0cd2e9d55
SF #859811, typo in docs
Neal Norwitz <nnorwitz@gmail.com>
parents:
29966
diff
changeset
|
92 need to be run in a special way. Use \program{pythonw} instead of \program{python} |
|
28578
8b49445c0a0e
Moved all the scripting stuff to a separate section, added all the
Jack Jansen <jack.jansen@cwi.nl>
parents:
28546
diff
changeset
|
93 to start such scripts. |
|
8b49445c0a0e
Moved all the scripting stuff to a separate section, added all the
Jack Jansen <jack.jansen@cwi.nl>
parents:
28546
diff
changeset
|
94 |
|
28546
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
95 \subsection{configuration} |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
96 |
|
29966
fe499bc7381f
Avoid a 301 permanent redirect.
Fred Drake <fdrake@acm.org>
parents:
28578
diff
changeset
|
97 MacPython honours all standard \UNIX{} environment variables such as |
|
fe499bc7381f
Avoid a 301 permanent redirect.
Fred Drake <fdrake@acm.org>
parents:
28578
diff
changeset
|
98 \envvar{PYTHONPATH}, but setting these variables for programs started |
|
fe499bc7381f
Avoid a 301 permanent redirect.
Fred Drake <fdrake@acm.org>
parents:
28578
diff
changeset
|
99 from the Finder is non-standard |
|
28546
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
100 as the Finder does not read your \file{.profile} or \file{.cshrc} at startup. |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
101 You need to create a file \file{\textasciitilde /.MacOSX/environment.plist}. |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
102 See Apple's Technical Document QA1067 for details. |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
103 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
104 Installing additional Python packages is most easily done through the |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
105 Package Manager, see the MacPython Help Book for details. |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
106 |
|
15229
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
107 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
108 \section{The IDE\label{IDE}} |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
109 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
110 The \program{Python IDE} (Integrated Development Environment) is a |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
111 separate application that acts as a text editor for your Python code, |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
112 a class browser, a graphical debugger, and more. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
113 |
|
34586
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
114 The online Python Help contains a quick walkthrough of the IDE that |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
115 shows the major features and how to use them. |
|
15229
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
116 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
117 \subsection{Using the ``Python Interactive'' window} |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
118 |
|
34586
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
119 Use this window like you would use a normal \UNIX{} command line |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
120 interpreter. |
|
15229
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
121 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
122 \subsection{Writing a Python Script \label{IDEwrite}} |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
123 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
124 In addition to using the \program{Python IDE} interactively, you can |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
125 also type out a complete Python program, saving it incrementally, and |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
126 execute it or smaller selections of it. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
127 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
128 You can create a new script, open a previously saved script, and save |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
129 your currently open script by selecting the appropriate item in the |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
130 ``File'' menu. Dropping a Python script onto the |
|
33647
5a292a03ea41
SF bug#1038917 fix typos (Contributed by George Yoshida.)
Raymond Hettinger <python@rcn.com>
parents:
32708
diff
changeset
|
131 \program{Python IDE} will open it for editing. |
|
15229
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
132 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
133 When the \program{Python IDE} saves a script, it uses the creator code |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
134 settings which are available by clicking on the small black triangle |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
135 on the top right of the document window, and selecting ``save |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
136 options''. The default is to save the file with the \program{Python |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
137 IDE} as the creator, this means that you can open the file for editing |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
138 by simply double-clicking on its icon. You might want to change this |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
139 behaviour so that it will be opened by the |
|
34586
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
140 \program{PythonLauncher}, and run. To do this simply choose |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
141 ``PythonLauncher'' from the ``save options''. Note that these |
|
15229
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
142 options are associated with the \emph{file} not the application. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
143 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
144 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
145 \subsection{Executing a script from within the IDE |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
146 \label{IDEexecution}} |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
147 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
148 You can run the script in the frontmost window of the \program{Python |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
149 IDE} by hitting the run all button. You should be aware, however that |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
150 if you use the Python convention \samp{if __name__ == "__main__":} the |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
151 script will \emph{not} be ``__main__'' by default. To get that |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
152 behaviour you must select the ``Run as __main__'' option from the |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
153 small black triangle on the top right of the document window. Note |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
154 that this option is associated with the \emph{file} not the |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
155 application. It \emph{will} stay active after a save, however; to shut |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
156 this feature off simply select it again. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
157 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
158 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
159 \subsection{``Save as'' versus ``Save as Applet'' |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
160 \label{IDEapplet}} |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
161 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
162 When you are done writing your Python script you have the option of |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
163 saving it as an ``applet'' (by selecting ``Save as applet'' from the |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
164 ``File'' menu). This has a significant advantage in that you can drop |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
165 files or folders onto it, to pass them to the applet the way |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
166 command-line users would type them onto the command-line to pass them |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
167 as arguments to the script. However, you should make sure to save the |
|
20821
ca418a5fa471
Correct misspelling of "separate" in two places.
Fred Drake <fdrake@acm.org>
parents:
17500
diff
changeset
|
168 applet as a separate file, do not overwrite the script you are |
|
15229
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
169 writing, because you will not be able to edit it again. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
170 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
171 Accessing the items passed to the applet via ``drag-and-drop'' is done |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
172 using the standard \member{sys.argv} mechanism. See the general |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
173 documentation for more |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
174 % need to link to the appropriate place in non-Mac docs |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
175 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
176 Note that saving a script as an applet will not make it runnable on a |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
177 system without a Python installation. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
178 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
179 %\subsection{Debugger} |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
180 % **NEED INFO HERE** |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
181 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
182 %\subsection{Module Browser} |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
183 % **NEED INFO HERE** |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
184 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
185 %\subsection{Profiler} |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
186 % **NEED INFO HERE** |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
187 % end IDE |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
188 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
189 %\subsection{The ``Scripts'' menu} |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
190 % **NEED INFO HERE** |
|
34586
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
191 |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
192 \section{The Package Manager} |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
193 |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
194 Historically MacPython came with a number of useful extension packages |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
195 included, because most Macintosh users do not have access to a development |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
196 environment and C compiler. For Mac OS X that bundling is no longer done, |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
197 but a new mechanism has been made available to allow easy access to |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
198 extension packages. |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
199 |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
200 The Python Package Manager helps you installing additional packages |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
201 that enhance Python. It determines the exact MacOS version and Python |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
202 version you have and uses that information to download a database that |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
203 has packages that are tested and tried on that combination. In other |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
204 words: if something is in your Package Manager window but does not work |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
205 you are free to blame the database maintainer. |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
206 |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
207 PackageManager then checks which of the packages you have installed and |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
208 which ones are not. This should also work when you have installed packages |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
209 outside of PackageManager. You can select packages and install them, |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
210 and PackageManager will work out the requirements and install these too. |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
211 |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
212 Often PackageManager will list a package in two flavors: binary and |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
213 source. Binary should always work, source will only work if you have |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
214 installed the Apple Developer Tools. PackageManager will warn you about |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
215 this, and also about other external dependencies. |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
216 |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
217 PackageManager is available as a separate application and also as a |
|
7e7e86f45255
Update refences to "Macintosh" to reflect the state of affairs for OS X and not
Brett Cannon <bcannon@gmail.com>
parents:
34296
diff
changeset
|
218 function of the IDE, through the File->Package Manager menu entry. |
