blob: 5048ac37c60e38c48ca9ac6d244f7478e8673d24 [file] [log] [blame]
Jack Jansen5f962c21996-04-10 14:52:59 +00001<HTML>
2<HEAD>
Jack Jansen8a6cdcc2000-09-10 12:02:28 +00003<TITLE>Using Python 2.0 on the Macintosh</TITLE>
Jack Jansen5f962c21996-04-10 14:52:59 +00004</HEAD>
5<BODY>
Jack Jansen8a6cdcc2000-09-10 12:02:28 +00006<H1>Using Python 2.0 on the Macintosh</H1>
Jack Jansen5f962c21996-04-10 14:52:59 +00007<HR>
8
Jack Jansenbd9565a1996-04-15 12:25:44 +00009This document is an introduction to using Python on the Apple
10Macintosh. It does not introduce the language itself, for this you
11should refer to the <A
12HREF="http://www.python.org/doc/tut/tut.html">Python Tutorial</A> by
13Guido van Rossum. This guide more-or-less replaces chapter two of the
14tutorial, and provides some additional material. <p>
Jack Jansen5f962c21996-04-10 14:52:59 +000015
Jack Jansen0fb1d821996-11-20 15:13:24 +000016The tutorial, along with other indispensible documentation like the
17library reference and such, is also available in a number of different
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000018formats at <a href="http://www.python.org">
19www.python.org</a>. The Adobe Acrobat <code>.pdf</code>
Jack Jansen0fb1d821996-11-20 15:13:24 +000020files are probably a good choice for reading or printing the documents
21from your mac. <p>
22
Jack Jansen08365421996-04-19 15:56:08 +000023There is currently no good tutorial for the mac-specific features of
24Python, but to whet your appetite: it has interfaces to many MacOS
25toolboxes (quickdraw, sound, quicktime, open scripting, etc) and
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000026various portable toolboxes are available too (Tk, complex
Jack Jansen08365421996-04-19 15:56:08 +000027numbers, image manipulation, etc). Some <A HREF="index.html">
28annotated sample programs</A> are available to give you an idea of
29Python's power. <P>
30
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000031<h2>Using Python</h2>
Jack Jansen5f962c21996-04-10 14:52:59 +000032
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000033The best way to start using Python is by using the <code>Python IDE</code>,
34an integrated development environment with editor, debugger, class browser, etc.
35Unfortunately the IDE is not yet documented here. Fortunately, however, it does not
36need much documentation, so your best bet is to try it. <p>
37
38<h2>Invoking the bare interpreter</h2>
39
40An alternative method to use Python (and the method this document unfortunately emphasizes,
41see the comment above) is to use the bare interpreter and an external text editor.
42The name of the interpreter is <CODE>PythonInterpreter</CODE> and it is
43recognizable by the "16 ton" icon. You start the
Jack Jansen08365421996-04-19 15:56:08 +000044interpreter in interactive mode by double-clicking its icon: <p>
Jack Jansen5f962c21996-04-10 14:52:59 +000045
46<img src="html.icons/python.gif"><p>
47
Jack Jansenbd9565a1996-04-15 12:25:44 +000048This should give you a text window with an informative version string
49and a prompt, something like the following:
Jack Jansen5f962c21996-04-10 14:52:59 +000050<PRE>
Jack Jansencf70b841998-04-27 15:07:20 +000051Python 1.5.1 (#122 Aug 27, 1997) [CW PPC w/GUSI MSL]
Jack Jansen3412c5d1997-08-27 14:08:22 +000052Copyright 1991-1997 Stichting Mathematisch Centrum, Amsterdam
Jack Jansen5f962c21996-04-10 14:52:59 +000053&gt;&gt;&gt;
54</PRE>
Jack Jansenbd9565a1996-04-15 12:25:44 +000055The version string tells you the version of Python, whether it was
56built for PPC or 68K macs and possibly some options used to build the
57interpreter. If you find a bug or have a question about how the
58interpreter works it is a good idea to include the version information
59in your message. <p>
Jack Jansen5f962c21996-04-10 14:52:59 +000060
Jack Jansenbd9565a1996-04-15 12:25:44 +000061At the prompt you can type interactive python commands. See the
62tutorial for more information. The interactive window works
63more-or-less like a Communication Toolbox or Telnet window: you type
64commands at the bottom and terminate them with the <EM>[return]</EM>
65or <EM>[enter]</EM> key. Interpreter feedback also appears at the
66bottom of the window, and the contents scroll as output is added. You
67can use copy and paste in the normal way, but be sure to paste only at
68the bottom of the document.
Jack Jansen5f962c21996-04-10 14:52:59 +000069
70<h2>Creating Python scripts</h2>
71
Jack Jansenbd9565a1996-04-15 12:25:44 +000072The Python interpreter works in a way that is different from what you
73would expect of a macintosh program: the interpreter is just that: an
74interpreter. There is no builtin editor or other development
75support. Hence, to create a Python script you need an external text
76editor. For a first script you can use any editor that can create
77plain, unstyled text files, such as <CODE>SimpleText</CODE>. <p>
Jack Jansen5f962c21996-04-10 14:52:59 +000078
Jack Jansenbd9565a1996-04-15 12:25:44 +000079For more serious scripts, though, it is advisable to use a programmers
80editor, such as <CODE>BBEdit</CODE> or <CODE>Alpha</CODE>. BBEdit is
81my favorite: it comes in a commercial version but also in a
82fully-functional free version <CODE>BBEdit Lite</CODE>. You can
83download it from the <A HREF="http://www.barebones.com/">BareBones</A>
84site. The free version will probably provide all the functionality
85you will ever need. Besides the standard edit facilities it has
86multi-file searches and many other goodies that can be very handy when
87editing programs. <p>
Jack Jansen5f962c21996-04-10 14:52:59 +000088
Jack Jansenbd9565a1996-04-15 12:25:44 +000089After you have created your script in the editor of your choice you
90drop it on the interpreter. This will start the interpreter executing
91the script, again with a console window in which the output appears
92and in which you can type input if the script requires it. Normally
93the interpreter will close the window and quit as soon as the script
94is done executing, see below under <A HREF="#startup">startup
95options</A> for a way to change this. <p>
Jack Jansen5f962c21996-04-10 14:52:59 +000096
Jack Jansen0fb1d821996-11-20 15:13:24 +000097<blockquote>
98There is a BBEdit extension available that allows you to run Python
99scripts more-or-less straight from your bbedit source window. Check
100out the <code>Mac:Tools:BBPy</code> folder.
101</blockquote>
102
Jack Jansenbd9565a1996-04-15 12:25:44 +0000103It is a good idea to have the names of all your scripts end in
104<CODE>.py</CODE>. While this is not necessary for standalone scripts
105it is needed for modules, and it is probably a good idea to start the
106habit now. <p>
107
108If you do not like to start the Python interpreter afresh for each
109edit-run cycle you can use the <CODE>import</CODE> statement and
110<CODE>reload()</CODE> function to speed things up in some cases. Here
111is Guido's original comment for how to do this, from the 1.1 release
112notes: <P>
113
Jack Jansen08365421996-04-19 15:56:08 +0000114<BLOCKQUOTE>
Jack Jansenbd9565a1996-04-15 12:25:44 +0000115
116Make sure the program is a module file (filename must be a Python
117identifier followed by '<CODE>.py</CODE>'). You can then import it
118when you test it for the first time. There are now three
119possibilities: it contains a syntax error; it gets a runtime error
120(unhandled exception); or it runs OK but gives wrong results. (If it
121gives correct results, you are done testing and don't need to read the
122rest of this paragraph. :-) Note that the following is not
123Mac-specific -- it's just that on UNIX it's easier to restart the
124entire script so it's rarely useful. <P>
125
126Recovery from a syntax error is easy: edit the file and import it
127again. <P>
128
129Recovery from wrong output is almost as easy: edit the file and,
130instead of importing it, call the function <CODE>reload()</CODE> with
131the module name as argument (e.g., if your module is called
132<CODE>foo</CODE>, type <CODE>reload(foo)</CODE>). <P>
133
134Recovery from an exception is trickier. Once the syntax is correct, a
135'module' entry is placed in an internal table, and following import
136statements will not re-read the file, even if the module's
137initialization terminated with an error (one reason why this is done
138is so that mutually recursive modules are initialized only once). You
139must therefore force re-reading the module with <CODE>reload()</CODE>,
140however, if this happens the first time you try to import the module,
141the import statement itself has not completed, and your workspace does
142not know the module name (even though the internal table of moduesl
143does!). The trick is to first import the module again, then reload
144it. For instance, <CODE>import foo; reload(foo)</CODE>. Because the
145module object already exists internally, the import statement does not
146attempt to execute the module again -- it just places it in your
Jack Jansen08365421996-04-19 15:56:08 +0000147workspace. </BLOCKQUOTE>
Jack Jansen5f962c21996-04-10 14:52:59 +0000148
149<h2>Clickable python scripts</h2>
150
Jack Jansenbd9565a1996-04-15 12:25:44 +0000151If you create your script with the correct creator and type, creator
152<CODE>'Pyth'</CODE> and type <CODE>'TEXT'</CODE>, you can double-click
153your script and it will automatically invoke the interpreter. If you
154use BBEdit you can tell it about the Python file type by adding it to
155the "file types" sections of the preferences. Then, if you save a file
156for the first time you can tell BBEdit to save the file as a Python
157script through the "options" choice of the save dialog. <p>
Jack Jansen5f962c21996-04-10 14:52:59 +0000158
Jack Jansenbd9565a1996-04-15 12:25:44 +0000159The <CODE>Scripts</CODE> folder contains a script
160<CODE>fixfiletypes</CODE> that will recursively traverse a folder and
161set the correct creator and type for all files ending in
162<CODE>.py</CODE>. <p>
Jack Jansen5f962c21996-04-10 14:52:59 +0000163
Jack Jansen08365421996-04-19 15:56:08 +0000164<BLOCKQUOTE>
165Older releases of Python used the creator code
166<CODE>'PYTH'</CODE> in stead of <CODE>'Pyth'</CODE>. If you still have
167older Python sources on your system and named them with
168<CODE>'.py'</CODE> extension the <CODE>fixfiletypes</CODE> script will
169correct them.
170</BLOCKQUOTE>
171
Jack Jansen5f962c21996-04-10 14:52:59 +0000172<h2>Interaction with the user</h2>
173
Jack Jansenbd9565a1996-04-15 12:25:44 +0000174Normally, the interpreter will check for user input (mouse clicks,
175keyboard input) every once in a while, so it is possible to switch to
176other applications while a script runs. It is also possible to
177interrupt the interpreter with the standard command-period keypress,
178this will raise the <CODE>KeyboardInterrupt</CODE> exception. Scripts
179may, however, turn off this behaviour to facilitate their own event
180handling. Such scripts can only be killed with the
181command-option-escape shortcut.
Jack Jansen5f962c21996-04-10 14:52:59 +0000182
183<h2><A NAME="startup">startup options</A></h2>
184
Jack Jansenbd9565a1996-04-15 12:25:44 +0000185If the <EM>option</EM> key is depressed when Python starts executing
186the interpreter will bring up an options dialog thru which you can
187influence the way the interpreter behaves. Keep the option key
188depressed until the dialog comes up. <p>
Jack Jansen5f962c21996-04-10 14:52:59 +0000189
190<img src="html.icons/options.gif"><p>
191
192The options modify the interpreters behaviour in the following way:
193<ul>
194<li> the interpreter goes to interactive mode (in stead of
195exiting) after a script has terminated normally,
196<li> for every module imported a line is printed telling you where the
197module was loaded from,
Jack Jansen3412c5d1997-08-27 14:08:22 +0000198<li> do not print the values of expressions executed as statements in
199an interactive python (obsolete),
Jack Jansen5f962c21996-04-10 14:52:59 +0000200<li> do not buffer stdout and stderr,
201<li> print some debugging output during the parsing phase,
202<li> keep the output window open when a script terminates.
203</ul>
Jack Jansenbd9565a1996-04-15 12:25:44 +0000204In addition, you can enter a unix-style command line which is passed
205to the script in <CODE>sys.argv</CODE>. Sys.argv[0] is always the name
206of the script being executed, additional values can be passed
207here. Quoting works as expected. <p>
Jack Jansen5f962c21996-04-10 14:52:59 +0000208
Jack Jansen22fa6421996-09-05 15:15:59 +0000209<BLOCKQUOTE>
210<EM>Warning:</EM> redirecting standard input or standard output in the
211command-line dialog does not work. This is due to circumstances beyond my
212control, hence I cannot say when this will be fixed.
213</BLOCKQUOTE>
214
Jack Jansenbd9565a1996-04-15 12:25:44 +0000215The default options are also settable on a system-wide basis, see the
216section on <A HREF="#preferences">editing preferences</A>. <p>
Jack Jansen5f962c21996-04-10 14:52:59 +0000217
218<h2>Module search path</h2>
219
Jack Jansenbd9565a1996-04-15 12:25:44 +0000220The module search path, <CODE>sys.path</CODE>, contains the folders
221python will search when you import a module. The path is settable on a
222system-wide basis (see the preferences section), and normally
223comprises the current folder (where the script lives), the
224<CODE>Lib</CODE> folder and some of its subfolders and possibly some
225more. <p>
Jack Jansen5f962c21996-04-10 14:52:59 +0000226
227<h2>Working folder</h2>
228
Jack Jansenbd9565a1996-04-15 12:25:44 +0000229The unix concept of a <I>working directory</I> does not translate
230directly to a similar concept on the Macintosh. To facilitate easy
231porting and the use of relative pathnames in scripts the interpreter
232simulates a working directory. When a script is started the initial
233working directory is the folder where the script lives. In case of an
234interactive interpreter the working directory is the folder where the
235interpreter lives. <P>
236
237By the way: the "standard file" folder, the folder that is presented
238to the user initially for an <I>open</I> or <I>save</I> dialog, does
239<EM>not</EM> follow the Python working directory. Which folder is
240initially shown to the user is usually one of (a) the application
241folder, (b) the "Documents" folder or (c) the folder most recently
242used for such a dialog (in any Python program). This is standard MacOS
243behaviour, so don't blame Python for it. The exact behaviour is
244settable through a control panel since System 7.5.
Jack Jansen5f962c21996-04-10 14:52:59 +0000245
246<h2>Interactive startup file</h2>
247
Jack Jansenbd9565a1996-04-15 12:25:44 +0000248If the folder containing the interpreter contains a file named
249<CODE>PythonStartup</CODE> this file is executed when you start an
250interactive interpreter. In this file you could import modules you
251often use and other such things. <p>
Jack Jansen5f962c21996-04-10 14:52:59 +0000252
253
254<h2>Compiled python scripts</h2>
255
Jack Jansenbd9565a1996-04-15 12:25:44 +0000256Once a python module has been imported the interpreter creates a
257compiled version which is stored in a file with the ".py" extension
258replaced by ".pyc". These compiled files, with creator
259<CODE>'Pyth'</CODE> and type <CODE>'PYC '</CODE> load faster when
260imported (because they do not have to be parsed). The <CODE>Lib</CODE>
261folder contains a script <CODE>compileall.py</CODE>, running this
262script will cause all modules along the python search path to be
263precompiled, which will speed up your programs. Compiled files are
264also double-clickable. <p>
Jack Jansen5f962c21996-04-10 14:52:59 +0000265
266<h2>Python resources</h2>
267
Jack Jansenbd9565a1996-04-15 12:25:44 +0000268MacPython has the ability to collect a number of compiled modules
269together in the resource fork of a single file. This feature is useful
270if you distribute a python program and want to minimize clutter: you
271can put all the needed modules in a single file (which could even be
272the interpreter itself). <p>
Jack Jansen5f962c21996-04-10 14:52:59 +0000273
Jack Jansenbd9565a1996-04-15 12:25:44 +0000274If the module search path contains a filename as one of its entries
275(as opposed to a folder name, which is the normal case) this file will
276be searched for a resource with type <CODE>'PYC '</CODE> and a name
277matching the module being imported. <p>
Jack Jansen5f962c21996-04-10 14:52:59 +0000278
Jack Jansenbd9565a1996-04-15 12:25:44 +0000279The <CODE>scripts</CODE> folder contains a script
280<CODE>PackLibDir</CODE> which will convert a number of modules (or
281possibly a complete subtree full of modules) into such a resource
282file.
Jack Jansen5f962c21996-04-10 14:52:59 +0000283
284<h2><A NAME="preferences">Setting interpreter preferences</A></h2>
285
Jack Jansenbd9565a1996-04-15 12:25:44 +0000286The python interpreter keeps a preferences file in the standard
287location in the system folder. In this preferences file it remembers
288the default module search path and the default settings for the
289runtime options. The preferences are settable via
Jack Jansen3412c5d1997-08-27 14:08:22 +0000290<CODE>EditPythonPrefs</CODE>. For PPC/cfm68k python this is a standalone
Jack Jansenbd9565a1996-04-15 12:25:44 +0000291program living in the main Python folder, for 68K python it is a
Jack Jansen3412c5d1997-08-27 14:08:22 +0000292script in the <CODE>Mac:Scripts</CODE> folder. <p>
Jack Jansen5f962c21996-04-10 14:52:59 +0000293
Jack Jansenbd9565a1996-04-15 12:25:44 +0000294The interface to edit the preferences is rather clunky for the current
295release. <p>
Jack Jansen5f962c21996-04-10 14:52:59 +0000296
297<img src="html.icons/preferences.gif"><p>
298
Jack Jansenbd9565a1996-04-15 12:25:44 +0000299In the editable text field at the top you enter the initial module
300search path, using newline as a separator. There are two special
301values you can use here: an initial substring <CODE>$(PYTHON)</CODE>
302will expand to the Python home folder and a value of
303<CODE>$(APPLICATION)</CODE> will expand to the the python application
304itself. Note that the text field may extend "beyond the bottom" even
305though it does not have a scroll bar. Using the arrow keys works,
306though.<p>
Jack Jansen5f962c21996-04-10 14:52:59 +0000307
Jack Jansen04d5c581997-10-10 15:50:37 +0000308The Python home folder $(PYTHON) is initially, when you install Python,
309set to the folder where the interpreter lives. You can change it here. <p>
Jack Jansen5f962c21996-04-10 14:52:59 +0000310
Jack Jansenbd9565a1996-04-15 12:25:44 +0000311Finally, you can set the default startup options here, through a
312sub-dialog.
Jack Jansen5f962c21996-04-10 14:52:59 +0000313
314<h2>Applets</h2>
315
Jack Jansenbd9565a1996-04-15 12:25:44 +0000316An applet is a fullblown application written in Python, similar to an
317AppleScript applet (and completely different from a Java
Jack Jansen0fb1d821996-11-20 15:13:24 +0000318applet). Applets are currently supported on PowerPC macintoshes and on
31968K macintoshes if you use the CFM68K version of the interpreter,
Jack Jansen3412c5d1997-08-27 14:08:22 +0000320and are created using the <CODE>BuildApplet</CODE> program. You create an
321applet by dropping the python source script onto BuildApplet.
Jack Jansen0fb1d821996-11-20 15:13:24 +0000322<a href="example2.html">Example 2</a> is a more involved applet
Jack Jansenbd9565a1996-04-15 12:25:44 +0000323with its own resource file, etc. <p>
Jack Jansen5f962c21996-04-10 14:52:59 +0000324
Jack Jansenbd9565a1996-04-15 12:25:44 +0000325Note that while an applet behaves as a fullblown Macintosh application
326it is not self-sufficient, so distributing it to a machine without an
327installed Python interpreter will not work: it needs the shared python
328execution engine <CODE>PythonCore</CODE>, and probably various modules
Jack Jansene2723031996-10-22 15:29:15 +0000329from the Lib and PlugIns folders. Distributing it to a machine that does
Jack Jansen3412c5d1997-08-27 14:08:22 +0000330have a Python system will work. <p>
Jack Jansen5f962c21996-04-10 14:52:59 +0000331
332<h2>Customizing applets</h2>
333
Jack Jansenbd9565a1996-04-15 12:25:44 +0000334Applets can have their own settings for the startup options and module
335search path. Dropping an applet on the <CODE>EditPythonPrefs</CODE>
336application allows you to set these, in the same way as
337double-clicking EditPythonPrefs allows you to set the system-wide
338defaults. <p>
Jack Jansen5f962c21996-04-10 14:52:59 +0000339
Jack Jansenbd9565a1996-04-15 12:25:44 +0000340Actually, not only applets but also the interpreter itself can have
341non-default settings for path and options. If you make a copy of the
342interpreter and drop this copy onto EditPythonPrefs you will have an
Jack Jansen0fb1d821996-11-20 15:13:24 +0000343interpreter that has a different set of default settings. <p>
Jack Jansen5f962c21996-04-10 14:52:59 +0000344
345<h2>Where to go from here</h2>
346
Jack Jansenbd9565a1996-04-15 12:25:44 +0000347The previously mentioned <A
348HREF="http://www.python.org/doc/tut/tut.html">Python Tutorial</A> is
349an excellent place to start reading if you have never used Python
350before. Other documentation such as the library reference manual is
351indexed at the <A HREF="http://www.python.org/doc/">Python
352Documentation</A> page. <p>
Jack Jansen5f962c21996-04-10 14:52:59 +0000353
Jack Jansenbd9565a1996-04-15 12:25:44 +0000354There are some <A HREF="index.html">annotated sample programs</A>
355available that show some mac-specific issues, like use of various
356toolboxes and creation of Python applets. <p>
Jack Jansen5f962c21996-04-10 14:52:59 +0000357
Jack Jansencf70b841998-04-27 15:07:20 +0000358The <CODE>Demo</CODE> and <CODE>Mac:Demo</CODE>
Jack Jansen0fb1d821996-11-20 15:13:24 +0000359folders in the Macintosh distribution
Jack Jansenbd9565a1996-04-15 12:25:44 +0000360contains a number of other example programs. Most of these are only
361very lightly documented, but they may help you to understand some
362aspects of using Python. <p>
Jack Jansen5f962c21996-04-10 14:52:59 +0000363
Jack Jansencf70b841998-04-27 15:07:20 +0000364Finally, there is a <code>Mac:Contrib</code> folder that contains
365a few contributions to Python that I couldn't fit in the normal tree
366but did want to distribute (many other contributions are contained
367throughout the distribution, but you don't see them, really).
368
Jack Jansen5f962c21996-04-10 14:52:59 +0000369The best way to contact fellow Macintosh Python programmers is to join
Jack Jansenbd9565a1996-04-15 12:25:44 +0000370the MacPython Special Interest Group mailing list. Send a message with
371"info" in the body to <A
372HREF="mailto:pythonmac-sig-request@python.org">pythonmac-sig-request@python.org</A>
373or view the <A
374HREF="http://www.python.org/sigs/pythonmac-sig/">Pythonmac SIG
375page</A> on the <A HREF="http://www.python.org">www.python.org</A> WWW
376server. <p>
Jack Jansen5f962c21996-04-10 14:52:59 +0000377
378<h2>Troubleshooting</h2>
379
Jack Jansene2723031996-10-22 15:29:15 +0000380A rather baffling error message can be "PythonCore not found" when you
381start the interpreter and you are sure that PythonCore is available. The
382message should actually say "Not enough memory in the system heap to
383load PythonCore".
384Blame Apple for the confusing message. <p>
385
Jack Jansen04d5c581997-10-10 15:50:37 +0000386There appear to be problems with QuickTime for the CFM68K version of the
387interpreter. If you experience these please contact the SIG: some people
388use quicktime without problems and some not, and we are still hunting for
389the cause. <p>
390
Jack Jansenbd9565a1996-04-15 12:25:44 +0000391Python is a rather safe language, and hence it should be difficult to
392crash the interpreter of the system with a Python script. There is an
393exception to this rule, though: the modules that interface to the
394system toolboxes (windowing, quickdraw, etc) do very little error
395checking and therefore a misbehaving program using these modules may
396indeed crash the system. Such programs are unfortunately rather
397difficult to debug, since the crash does not generate the standard
398Python stack trace, obviously, and since debugging print statements
399will often interfere with the operation of the program. There is
400little to do about this currently. <p>
Jack Jansen5f962c21996-04-10 14:52:59 +0000401
Jack Jansenbd9565a1996-04-15 12:25:44 +0000402Probably the most common cause of problems with modules ported from
403other systems is the Mac end-of-line convention. Where unix uses
Jack Jansend9585c91996-05-07 15:28:20 +0000404linefeed, 0x0a, to separate lines the mac uses carriage return,
4050x0d. To complicate matters more a lot of mac programming editors like
Jack Jansenbd9565a1996-04-15 12:25:44 +0000406BBEdit and emacs will work happily with both conventions, so the file
407will appear to be correct in the editor but cause strange errors when
408imported. BBEdit has a popup menu which allows you to inspect (and
409set) the end-of-line convention used in a file. <p>
Jack Jansen5f962c21996-04-10 14:52:59 +0000410
Jack Jansene2723031996-10-22 15:29:15 +0000411Python attempts to keep its preferences file up-to-date even when you
412move the Python folder around, etc. If this fails the effect will be
413that Python cannot start or, worse, that it does work but it cannot find
Jack Jansen3412c5d1997-08-27 14:08:22 +0000414any standard modules. In this case, start Python and examine <code>sys.path</code>.
Jack Jansen0fb1d821996-11-20 15:13:24 +0000415If it is incorrect remove any Python preferences file from the system
Jack Jansene2723031996-10-22 15:29:15 +0000416folder and start the interpreter <em>while the interpreter sits in the main
Jack Jansen3412c5d1997-08-27 14:08:22 +0000417Python folder</em>. This will regenerate the preferences file. You may also
418have to run the ConfigurePython applet again. <p>
Jack Jansene2723031996-10-22 15:29:15 +0000419
Jack Jansencf70b841998-04-27 15:07:20 +0000420<h2>Your five minutes are up. Next!</h2>
Jack Jansen024a3871996-07-18 16:07:05 +0000421
422The next section to check out is the <a href="index.html">annotated sample programs</a>.<p>
423
Jack Jansen5f962c21996-04-10 14:52:59 +0000424<HR>
425<A HREF="http://www.cwi.nl/~jack">Jack Jansen</A>,
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000426<A HREF="mailto:jack@cwi.nl">jack@cwi.nl</A>, 10-Sep-00.
Jack Jansen5f962c21996-04-10 14:52:59 +0000427
428</BODY>
429</HTML>