Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 1 | Subject: FAQ: Python -- an object-oriented language |
Guido van Rossum | 5333c5d | 1994-04-11 11:06:22 +0000 | [diff] [blame] | 2 | Newsgroups: comp.lang.python,comp.answers,news.answers |
| 3 | Followup-to: comp.lang.python |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 4 | From: guido@cwi.nl (Guido van Rossum) |
| 5 | Reply-to: guido@cwi.nl (Guido van Rossum) |
| 6 | Approved: news-answers-request@MIT.Edu |
| 7 | |
| 8 | Archive-name: python-faq/part1 |
Guido van Rossum | c50158e | 1994-05-31 09:18:50 +0000 | [diff] [blame] | 9 | Version: 1.8 |
| 10 | Last-modified: 15 May 1994 |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 11 | |
| 12 | This article contains answers to Frequently Asked Questions about |
| 13 | Python (an object-oriented interpreted programming language -- see |
| 14 | the answer to question 1.1 for a short overview). |
| 15 | |
| 16 | Copyright 1993, 1994 Guido van Rossum. Unchanged electronic |
| 17 | redistribution of this FAQ is allowed. Printed redistribution only |
| 18 | with permission of the author. No warranties. |
| 19 | |
| 20 | Author's address: |
| 21 | Guido van Rossum |
| 22 | CWI, dept. CST |
| 23 | Kruislaan 413 |
| 24 | P.O. Box 94079 |
| 25 | 1090 GB Amsterdam |
| 26 | The Netherlands |
| 27 | Email: guido@cwi.nl |
| 28 | |
| 29 | The latest version of this FAQ is available by anonymous ftp from |
| 30 | ftp.cwi.nl [192.16.184.180] in the directory /pub/python, with |
| 31 | filename python-FAQ. It will also be posted regularly to the |
Guido van Rossum | 5333c5d | 1994-04-11 11:06:22 +0000 | [diff] [blame] | 32 | newsgroups comp.answers and comp.lang.python. |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 33 | |
| 34 | Many FAQs, including this one, are available by anonymous ftp from |
| 35 | rtfm.mit.edu [18.70.0.209] in the directory pub/usenet/news.answers. |
| 36 | The name under which a FAQ is archived appears in the Archive-name line |
| 37 | at the top of the article. This FAQ is archived as python-faq/part1. |
| 38 | |
| 39 | There's a mail server on that machine which will send you files from |
| 40 | the archive by e-mail if you have no ftp access. You send a e-mail |
| 41 | message to mail-server@rtfm.mit.edu containing the single word help in |
| 42 | the message body to receive instructions. |
| 43 | |
| 44 | This FAQ is divided in the following chapters: |
| 45 | |
| 46 | 1. General information and availability |
| 47 | 2. Python in the real world |
| 48 | 3. Building Python |
| 49 | 4. Programming in Python |
| 50 | 5. Extending Python |
| 51 | 6. Python's design |
| 52 | 7. Using Python on non-UNIX platforms |
| 53 | |
| 54 | To find the start of a particular chapter, search for the chapter number |
| 55 | followed by a dot and a space at the beginning of a line (e.g. to |
| 56 | find chapter 4 in vi, type /^4\. /). |
| 57 | |
| 58 | Here's an overview of the questions per chapter: |
| 59 | |
| 60 | 1. General information and availability |
| 61 | 1.1. Q. What is Python? |
| 62 | 1.2. Q. Why is it called Python? |
| 63 | 1.3. Q. How do I obtain a copy of the Python source? |
| 64 | 1.4. Q. How do I get documentation on Python? |
Guido van Rossum | c50158e | 1994-05-31 09:18:50 +0000 | [diff] [blame] | 65 | 1.5. Q. Are there other ftp sites that mirror the Python distribution? |
| 66 | 1.6. Q. Is there a newsgroup or mailing list devoted to Python? |
| 67 | 1.7. Q. Is there a book on Python, or will there be one out soon? |
| 68 | 1.8. Q. Are there any published articles about Python that I can quote? |
| 69 | 1.9. Q. How does the Python version numbering scheme work? |
| 70 | 1.10. Q. Are there other ftp sites that carry Python related material? |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 71 | |
| 72 | 2. Python in the real world |
| 73 | 2.1. Q. How many people are using Python? |
| 74 | 2.2. Q. Have any significant projects been done in Python? |
| 75 | 2.3. Q. Are there any commercial projects going on using Python? |
Guido van Rossum | 95f61a7 | 1994-01-26 17:23:37 +0000 | [diff] [blame] | 76 | 2.4. Q. How stable is Python? |
| 77 | 2.5. Q. What new developments are expected for Python in the future? |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 78 | |
| 79 | 3. Building Python |
Guido van Rossum | 91f6083 | 1994-02-15 15:52:27 +0000 | [diff] [blame] | 80 | 3.1. Q. Is there a test set? |
| 81 | 3.2. Q. When running the test set, I get complaints about floating point |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 82 | operations, but when playing with floating point operations I cannot |
| 83 | find anything wrong with them. |
Guido van Rossum | 91f6083 | 1994-02-15 15:52:27 +0000 | [diff] [blame] | 84 | 3.3. Q. Link errors building Python with STDWIN on SGI IRIX. |
| 85 | 3.4. Q. Link errors after rerunning the configure script. |
| 86 | 3.5. Q. The python interpreter complains about options passed to a |
Guido van Rossum | 2434999 | 1994-02-02 14:12:45 +0000 | [diff] [blame] | 87 | script (after the script name). |
Guido van Rossum | 91f6083 | 1994-02-15 15:52:27 +0000 | [diff] [blame] | 88 | 3.6. Q. When building on the SGI, make tries to run python to create |
Guido van Rossum | 5333c5d | 1994-04-11 11:06:22 +0000 | [diff] [blame] | 89 | glmodule.c, but python hasn't been built or installed yet. |
Guido van Rossum | 44b4cb1 | 1994-05-04 13:28:51 +0000 | [diff] [blame] | 90 | 3.7. Q. Other trouble building Python 1.0.2 on platform X. |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 91 | |
| 92 | 4. Programming in Python |
Guido van Rossum | 2434999 | 1994-02-02 14:12:45 +0000 | [diff] [blame] | 93 | 4.1. Q. Is there a source code level debugger with breakpoints, step, |
| 94 | etc.? |
| 95 | 4.2. Q. Can I create an object class with some methods implemented in |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 96 | C and others in Python (e.g. through inheritance)? (Also phrased as: |
| 97 | Can I use a built-in type as base class?) |
Guido van Rossum | 2434999 | 1994-02-02 14:12:45 +0000 | [diff] [blame] | 98 | 4.3. Q. Is there a curses/termcap package for Python? |
| 99 | 4.4. Q. Is there an equivalent to C's onexit() in Python? |
| 100 | 4.5. Q. When I define a function nested inside another function, the |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 101 | nested function seemingly can't access the local variables of the |
| 102 | outer function. What is going on? How do I pass local data to a |
| 103 | nested function? |
Guido van Rossum | 2434999 | 1994-02-02 14:12:45 +0000 | [diff] [blame] | 104 | 4.6. Q. How do I iterate over a sequence in reverse order? |
| 105 | 4.7. Q. My program is too slow. How do I speed it up? |
| 106 | 4.8. Q. When I have imported a module, then edit it, and import it |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 107 | again (into the same Python process), the changes don't seem to take |
| 108 | place. What is going on? |
Guido van Rossum | 2434999 | 1994-02-02 14:12:45 +0000 | [diff] [blame] | 109 | 4.9. Q. I have a module in which I want to execute some extra code when it |
| 110 | is run as a script. How do I find out whether I am running as a |
| 111 | script? |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 112 | |
| 113 | 5. Extending Python |
| 114 | 5.1. Q. Can I create my own functions in C? |
| 115 | 5.2. Q. Can I create my own functions in C++? |
| 116 | |
| 117 | 6. Python's design |
| 118 | 6.1. Q. Why isn't there a generic copying operation for objects in |
| 119 | Python? |
| 120 | 6.2. Q. Why isn't there a generic way to implement persistent objects |
| 121 | in Python? (Persistent == automatically saved to and restored from |
| 122 | disk.) |
| 123 | 6.3. Q. Why isn't there a switch or case statement in Python? |
Guido van Rossum | c50158e | 1994-05-31 09:18:50 +0000 | [diff] [blame] | 124 | 6.4. Q. Why does Python use indentation for grouping of statements? |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 125 | |
| 126 | 7. Using Python on non-UNIX platforms |
Guido van Rossum | 91f6083 | 1994-02-15 15:52:27 +0000 | [diff] [blame] | 127 | 7.1. Q. Is there a Mac version of Python? |
| 128 | 7.2. Q. Is there a DOS version of Python? |
| 129 | 7.3. Q. Is there a Windows version of Python? |
| 130 | 7.4. Q. Is there a Windows NT version of Python? |
| 131 | 7.5. Q. I have the DOS or Windows version but it appears to be only a |
| 132 | binary. Where's the library? |
| 133 | 7.6. Q. Where's the documentation for the Mac or PC version? |
| 134 | 7.7. Q. The Mac (PC) version doesn't seem to have any facilities for |
| 135 | creating or editing programs apart from entering it interactively, and |
| 136 | there seems to be no way to save code that was entered interactively. |
| 137 | How do I create a Python program on the Mac (PC)? |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 138 | |
| 139 | To find a particular question, search for the question number followed |
| 140 | by a dot, a space, and a Q at the beginning of a line (e.g. to find |
| 141 | question 4.2 in vi, type /^4\.2\. Q/). |
| 142 | |
| 143 | |
| 144 | 1. General information and availability |
| 145 | ======================================= |
| 146 | |
| 147 | 1.1. Q. What is Python? |
| 148 | |
| 149 | A. Python is an interpreted, interactive, object-oriented programming |
| 150 | language. It incorporates modules, exceptions, dynamic typing, very |
| 151 | high level dynamic data types, and classes. Python combines |
| 152 | remarkable power with very clear syntax. It has interfaces to many |
| 153 | system calls and libraries, as well as to various window systems, and |
| 154 | is extensible in C or C++. It is also usable as an extension language |
| 155 | for applications that need a programmable interface. Finally, Python |
| 156 | is portable: it runs on many brands of UNIX, on the Mac, and on |
| 157 | MS-DOS. |
| 158 | |
| 159 | To find out more, the best thing to do is to start reading the |
| 160 | tutorial from the documentation set (see a few questions further |
| 161 | down). |
| 162 | |
| 163 | 1.2. Q. Why is it called Python? |
| 164 | |
| 165 | A. Apart from being a computer wizard, I'm also a fan of "Monty |
| 166 | Python's Flying Circus" (a BBC comedy series from the seventies, in |
Guido van Rossum | 5333c5d | 1994-04-11 11:06:22 +0000 | [diff] [blame] | 167 | the -- unlikely -- case you didn't know). It occurred to me one day |
| 168 | that I needed a name that was short, unique, and slightly mysterious. |
| 169 | And I happened to be reading some scripts from the series at the |
| 170 | time... So then I decided to call my language Python. But Python is |
| 171 | not a joke. And don't you associate it with dangerous reptiles |
| 172 | either! |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 173 | |
| 174 | 1.3. Q. How do I obtain a copy of the Python source? |
| 175 | |
| 176 | A. The latest Python source distribution is always available by |
| 177 | anonymous ftp from ftp.cwi.nl [192.16.184.180] in the directory |
Guido van Rossum | 44b4cb1 | 1994-05-04 13:28:51 +0000 | [diff] [blame] | 178 | /pub/python, with filename python<version>.tar.gz. (Old versions may |
| 179 | have an extension of .Z, indicating use of "compress" compression.) |
| 180 | It is a gzip'ed tar file containing the complete C source, LaTeX |
| 181 | documentation, Python library modules, example programs, and several |
| 182 | useful pieces of freely distributable software. This will compile and |
| 183 | run out of the box on most UNIX platforms. At the time of writing, |
| 184 | <version> is 1.0.2. (See section 7 for non-UNIX information.) |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 185 | |
| 186 | 1.4. Q. How do I get documentation on Python? |
| 187 | |
| 188 | A. The latest Python documentation set is always available by |
| 189 | anonymous ftp from ftp.cwi.nl [192.16.184.180] in the directory |
Guido van Rossum | 44b4cb1 | 1994-05-04 13:28:51 +0000 | [diff] [blame] | 190 | /pub/python, with filename pythondoc-ps<version>.tar.gz. It is a |
| 191 | gzip'ed tar file containing PostScript files of the reference manual, |
| 192 | the library manual, and the tutorial. At the time of writing |
| 193 | <version> is 1.0.2. Note that the library manual is the most |
| 194 | important one of the set, as much of Python's power stems from the |
| 195 | standard or built-in types, functions and modules, all of which are |
| 196 | described here. PostScript for a high-level description of Python is |
| 197 | in the file nluug-paper.ps. |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 198 | |
Guido van Rossum | c50158e | 1994-05-31 09:18:50 +0000 | [diff] [blame] | 199 | 1.5. Q. Are there other ftp sites that mirror the Python distribution? |
| 200 | |
| 201 | A. The following sites keep mirrors of the Python distribution: |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 202 | |
| 203 | Site IP address Directory |
| 204 | |
| 205 | gatekeeper.dec.com 16.1.0.2 /pub/plan/python/cwi |
| 206 | ftp.uu.net 192.48.96.9 /languages/python |
| 207 | ftp.wustl.edu 128.252.135.4 /graphics/graphics/sgi-stuff/python |
Guido van Rossum | c50158e | 1994-05-31 09:18:50 +0000 | [diff] [blame] | 208 | ftp.funet.fi 128.214.6.100 /pub/languages/python |
Guido van Rossum | 5333c5d | 1994-04-11 11:06:22 +0000 | [diff] [blame] | 209 | ftp.fu-berlin.de 130.133.4.50 /pub/unix/languages/python (*python* only) |
Guido van Rossum | c50158e | 1994-05-31 09:18:50 +0000 | [diff] [blame] | 210 | ftp.sunet.se 130.238.127.3 /pub/lang/python |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 211 | |
Guido van Rossum | 5333c5d | 1994-04-11 11:06:22 +0000 | [diff] [blame] | 212 | Or try archie on e.g. python1.0 to locate the nearest copy of that |
| 213 | version... |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 214 | |
Guido van Rossum | c50158e | 1994-05-31 09:18:50 +0000 | [diff] [blame] | 215 | 1.6. Q. Is there a newsgroup or mailing list devoted to Python? |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 216 | |
Guido van Rossum | 5333c5d | 1994-04-11 11:06:22 +0000 | [diff] [blame] | 217 | A. There is a newsgroup, comp.lang.python, and a mailing list. The |
| 218 | newsgroup and mailing list are gatewayed into each other -- if you can |
| 219 | read news it is not necessary to subscribe to the mailing list. Send |
| 220 | e-mail to python-list-request@cwi.nl to (un)subscribe to the mailing |
| 221 | list. |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 222 | |
Guido van Rossum | c50158e | 1994-05-31 09:18:50 +0000 | [diff] [blame] | 223 | 1.7. Q. Is there a book on Python, or will there be one out soon? |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 224 | |
| 225 | A. Unfortunately, not yet. I would like to write one but my |
| 226 | obligations at CWI include too much other work to make much progress |
| 227 | on it. Several parties have expressed interest in sponsoring or |
| 228 | helping the production of a book or reference manual, but so far there |
| 229 | are no firm plans. If you volunteer help, by all means drop me a |
| 230 | note! |
| 231 | |
Guido van Rossum | c50158e | 1994-05-31 09:18:50 +0000 | [diff] [blame] | 232 | 1.8. Q. Are there any published articles about Python that I can quote? |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 233 | |
| 234 | A. So far the only refereed and published article that describes |
| 235 | Python in some detail is: |
| 236 | |
| 237 | Guido van Rossum and Jelke de Boer, "Interactively Testing Remote |
| 238 | Servers Using the Python Programming Language", CWI Quarterly, Volume |
| 239 | 4, Issue 4 (December 1991), Amsterdam, pp 283-303. |
| 240 | |
| 241 | LaTeX source for this paper is available as part of the Python source |
| 242 | distribution. |
| 243 | |
| 244 | A more recent high-level description of Python is: |
| 245 | |
| 246 | Guido van Rossum, "An Introduction to Python for UNIX/C |
| 247 | Programmers", in the proceedings of the NLUUG najaarsconferentie |
| 248 | 1993 (dutch UNIX users group meeting november 1993). |
| 249 | |
| 250 | PostScript for this paper and for the slides used for the accompanying |
| 251 | presentation can be found in the ftp directory mentioned a few |
| 252 | questions earlier, with filenames nluug-paper.ps and nluug-slides.ps, |
| 253 | respectively. |
| 254 | |
Guido van Rossum | c50158e | 1994-05-31 09:18:50 +0000 | [diff] [blame] | 255 | 1.9. Q. How does the Python version numbering scheme work? |
Guido van Rossum | 95f61a7 | 1994-01-26 17:23:37 +0000 | [diff] [blame] | 256 | |
| 257 | A. Python versions are numbered A.B.C. A is the major version number |
| 258 | -- it is only incremented for major changes in functionality or source |
| 259 | structure. B is the minor version number, incremented for less |
| 260 | earth-shattering changes to a release. C is the patchlevel -- it is |
| 261 | incremented for each new release. Note that in the past, patches have |
| 262 | added significant changes; in fact the changeover from 0.9.9 to 1.0.0 |
| 263 | was the first time that either A or B changed! |
| 264 | |
Guido van Rossum | c50158e | 1994-05-31 09:18:50 +0000 | [diff] [blame] | 265 | 1.10. Q. Are there other ftp sites that carry Python related material? |
Guido van Rossum | 5333c5d | 1994-04-11 11:06:22 +0000 | [diff] [blame] | 266 | |
| 267 | A. An interesting ftp site for Python users is ftp.markv.com |
| 268 | (192.122.251.1); the directory pub/python contains a growing |
| 269 | collection of interesting Python scripts. To submit a script for |
| 270 | inclusion, place it together with a readme file (with extension |
| 271 | .readme) in the publicly writable directory /incoming/python. This |
| 272 | service is maintained by Lance Ellinghouse <lance@markv.com>. |
| 273 | |
| 274 | |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 275 | |
| 276 | 2. Python in the real world |
| 277 | =========================== |
| 278 | |
| 279 | 2.1. Q. How many people are using Python? |
| 280 | |
Guido van Rossum | 5333c5d | 1994-04-11 11:06:22 +0000 | [diff] [blame] | 281 | A. I don't know, but the maximum number of simultaneous subscriptions |
| 282 | to the Python mailing list before it was gatewayed into the newsgroup |
| 283 | was about 180 (several of which were local redistribution lists). I |
| 284 | believe that many active Python users don't bother to subscribe to the |
| 285 | list, and now that there's a newsgroup the mailing list subscription |
| 286 | is even less meaningful. |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 287 | |
| 288 | 2.2. Q. Have any significant projects been done in Python? |
| 289 | |
| 290 | A. Here at CWI (the home of Python), we have written a 20,000 line |
| 291 | authoring environment for transportable hypermedia presentations, a |
Guido van Rossum | 5333c5d | 1994-04-11 11:06:22 +0000 | [diff] [blame] | 292 | 5,000 line multimedia teleconferencing tool, as well as many many |
| 293 | smaller programs. |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 294 | |
| 295 | The University of Virginia uses Python to control a virtual reality |
| 296 | engine. Contact: Matt Conway <conway@virginia.edu>. |
| 297 | |
| 298 | See also the next question. |
| 299 | |
| 300 | 2.3. Q. Are there any commercial projects going on using Python? |
| 301 | |
| 302 | A. Several companies have revealed to me that they are planning or |
| 303 | considering to use Python in a future product. The furthest is |
| 304 | Sunrise Software, who already have a product out using Python -- they |
| 305 | use Python for a GUI management application and an SNMP network |
| 306 | manangement application. Contact: <info@sunrise.com>. |
| 307 | |
| 308 | Individuals at many other companies are using Python for |
| 309 | internal development (witness their contributions to the Python |
Guido van Rossum | 5333c5d | 1994-04-11 11:06:22 +0000 | [diff] [blame] | 310 | mailing list or newsgroup). |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 311 | |
| 312 | Python has also been elected as an extension language by MADE, a |
| 313 | consortium supported by the European Committee's ESPRIT program and |
| 314 | consisting of Bull, CWI and some other European companies. Contact: |
| 315 | Ivan Herman <ivan@cwi.nl>. |
| 316 | |
Guido van Rossum | 95f61a7 | 1994-01-26 17:23:37 +0000 | [diff] [blame] | 317 | 2.4. Q. How stable is Python? |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 318 | |
Guido van Rossum | 44b4cb1 | 1994-05-04 13:28:51 +0000 | [diff] [blame] | 319 | A. Very stable. While the current version number (1.0.2) would |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 320 | suggest it is in the early stages of development, in fact new, stable |
Guido van Rossum | 95f61a7 | 1994-01-26 17:23:37 +0000 | [diff] [blame] | 321 | releases (numbered 0.9.x) have been coming out roughly every 3 to 6 |
| 322 | months for the past four years. |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 323 | |
Guido van Rossum | 95f61a7 | 1994-01-26 17:23:37 +0000 | [diff] [blame] | 324 | 2.5. Q. What new developments are expected for Python in the future? |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 325 | |
Guido van Rossum | 95f61a7 | 1994-01-26 17:23:37 +0000 | [diff] [blame] | 326 | A. Without warranty that any of this will actually be realized: I am |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 327 | currently thinking about mechanisms for built-in on-line help and a |
Guido van Rossum | 99bf250 | 1994-01-26 17:30:41 +0000 | [diff] [blame] | 328 | switch/case statement. There have been some discussions on |
| 329 | hierarchical module names which might solve the problem of the |
| 330 | development of large packages. A pthreads interface has been |
| 331 | contributed which I would like to merge into the latest release. The |
| 332 | X interface needs improving. There are also some people |
| 333 | (independently) working on a windowing interface based on STDWIN but |
| 334 | with the power and ease of use of the average modern widget set. I |
| 335 | still hope to get some help in producing a Windows version. It would |
| 336 | be nice if there were a window-based class browser (Someone at CWI has |
| 337 | contributed one using Motif but it needs some work). Also: improved |
| 338 | support for embedding Python in other applications, e.g. by renaming |
| 339 | most global symbols to have a "Py" prefix and providing more |
| 340 | documentation and threading support. |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 341 | |
| 342 | |
| 343 | 3. Building Python |
| 344 | ================== |
| 345 | |
Guido van Rossum | 91f6083 | 1994-02-15 15:52:27 +0000 | [diff] [blame] | 346 | 3.1. Q. Is there a test set? |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 347 | |
| 348 | A. Yes, simply do "import testall" (or "import autotest" if you aren't |
| 349 | interested in the output). The standard modules whose name begins |
| 350 | with "test" together comprise the test. The test set doesn't test |
| 351 | *all* features of Python but it goes a long way to confirm that a new |
| 352 | port is actually working. The Makefile contains an entry "make test" |
| 353 | which runs the autotest module. |
| 354 | |
Guido van Rossum | 91f6083 | 1994-02-15 15:52:27 +0000 | [diff] [blame] | 355 | 3.2. Q. When running the test set, I get complaints about floating point |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 356 | operations, but when playing with floating point operations I cannot |
| 357 | find anything wrong with them. |
| 358 | |
| 359 | A. The test set makes occasional unwarranted assumptions about the |
| 360 | semantics of C floating point operations. Until someone donates a |
| 361 | better floating point test set, you will have to comment out the |
| 362 | offending floating point tests and execute similar tests manually. |
| 363 | |
Guido van Rossum | 91f6083 | 1994-02-15 15:52:27 +0000 | [diff] [blame] | 364 | 3.3. Q. Link errors building Python with STDWIN on SGI IRIX. |
Guido van Rossum | 2434999 | 1994-02-02 14:12:45 +0000 | [diff] [blame] | 365 | |
| 366 | A. Rebuild STDWIN, specifying "CC=cc -cckr" in the Makefile. |
| 367 | |
Guido van Rossum | 91f6083 | 1994-02-15 15:52:27 +0000 | [diff] [blame] | 368 | 3.4. Q. Link errors after rerunning the configure script. |
Guido van Rossum | 2434999 | 1994-02-02 14:12:45 +0000 | [diff] [blame] | 369 | |
| 370 | A. It is generally necessary to run "make clean" after a configuration |
| 371 | change. |
| 372 | |
Guido van Rossum | 91f6083 | 1994-02-15 15:52:27 +0000 | [diff] [blame] | 373 | 3.5. Q. The python interpreter complains about options passed to a |
Guido van Rossum | 2434999 | 1994-02-02 14:12:45 +0000 | [diff] [blame] | 374 | script (after the script name). |
| 375 | |
| 376 | A. You are probably linking with GNU getopt, e.g. through -liberty. |
| 377 | Don't. (If you are using this because you link with -lreadline, use |
| 378 | the readline distributed with Python instead.) |
| 379 | |
Guido van Rossum | 91f6083 | 1994-02-15 15:52:27 +0000 | [diff] [blame] | 380 | 3.6. Q. When building on the SGI, make tries to run python to create |
Guido van Rossum | 2434999 | 1994-02-02 14:12:45 +0000 | [diff] [blame] | 381 | glmodule.c, but python hasn't been built or installed yet. |
| 382 | |
| 383 | A. Comment out the line mentioning glmodule.c in Setup and build a |
| 384 | python without gl first; install it or make sure it is in your $PATH, |
| 385 | then edit the Setup file again to turn on the gl module, and make |
| 386 | again. You don't need to do "make clean"; you do need to run "make |
| 387 | Makefile" in the Modules subdirectory (or just run "make" at the |
| 388 | toplevel). |
| 389 | |
Guido van Rossum | 44b4cb1 | 1994-05-04 13:28:51 +0000 | [diff] [blame] | 390 | 3.7. Q. Other trouble building Python 1.0.2 on platform X. |
Guido van Rossum | 95f61a7 | 1994-01-26 17:23:37 +0000 | [diff] [blame] | 391 | |
| 392 | A. Please email the details to <guido@cwi.nl> and I'll look into it. |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 393 | |
| 394 | |
| 395 | 4. Programming in Python |
| 396 | ======================== |
| 397 | |
Guido van Rossum | 2434999 | 1994-02-02 14:12:45 +0000 | [diff] [blame] | 398 | 4.1. Q. Is there a source code level debugger with breakpoints, step, |
| 399 | etc.? |
| 400 | |
| 401 | A. Yes. Check out module pdb; pdb.help() prints the documentation (or |
| 402 | you can read it as Lib/pdb.doc). If you use the STDWIN option, |
| 403 | there's also a windowing interface, wdb. You can write your own |
| 404 | debugger by using the code for pdb or wdb as an example. |
| 405 | |
| 406 | 4.2. Q. Can I create an object class with some methods implemented in |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 407 | C and others in Python (e.g. through inheritance)? (Also phrased as: |
| 408 | Can I use a built-in type as base class?) |
| 409 | |
| 410 | A. No, but you can easily create a Python class which serves as a |
| 411 | wrapper around a built-in object, e.g. (for dictionaries): |
| 412 | |
| 413 | # A user-defined class behaving almost identical |
| 414 | # to a built-in dictionary. |
| 415 | class UserDict: |
| 416 | def __init__(self): self.data = {} |
| 417 | def __repr__(self): return repr(self.data) |
| 418 | def __cmp__(self, dict): |
| 419 | if type(dict) == type(self.data): |
| 420 | return cmp(self.data, dict) |
| 421 | else: |
| 422 | return cmp(self.data, dict.data) |
| 423 | def __len__(self): return len(self.data) |
| 424 | def __getitem__(self, key): return self.data[key] |
| 425 | def __setitem__(self, key, item): self.data[key] = item |
| 426 | def __delitem__(self, key): del self.data[key] |
| 427 | def keys(self): return self.data.keys() |
| 428 | def items(self): return self.data.items() |
| 429 | def values(self): return self.data.values() |
| 430 | def has_key(self, key): return self.data.has_key(key) |
| 431 | |
Guido van Rossum | 2434999 | 1994-02-02 14:12:45 +0000 | [diff] [blame] | 432 | 4.3. Q. Is there a curses/termcap package for Python? |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 433 | |
| 434 | A. No, but you can use the "alfa" (== character cell) version of |
| 435 | STDWIN. (STDWIN == Standard Windows, a portable windowing system |
Guido van Rossum | 91f6083 | 1994-02-15 15:52:27 +0000 | [diff] [blame] | 436 | interface by the same author, URL: ftp://ftp.cwi.nl/pub/stdwin.) |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 437 | This will also prepare your program for porting to windowing |
| 438 | environments such as X11 or the Macintosh. |
| 439 | |
Guido van Rossum | 2434999 | 1994-02-02 14:12:45 +0000 | [diff] [blame] | 440 | 4.4. Q. Is there an equivalent to C's onexit() in Python? |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 441 | |
| 442 | A. Yes, if you import sys and assign a function to sys.exitfunc, it |
| 443 | will be called when your program exits, is killed by an unhandled |
| 444 | exception, or (on UNIX) receives a SIGHUP or SIGTERM signal. |
| 445 | |
Guido van Rossum | 2434999 | 1994-02-02 14:12:45 +0000 | [diff] [blame] | 446 | 4.5. Q. When I define a function nested inside another function, the |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 447 | nested function seemingly can't access the local variables of the |
| 448 | outer function. What is going on? How do I pass local data to a |
| 449 | nested function? |
| 450 | |
| 451 | A. Python does not have arbitrarily nested scopes. When you need to |
| 452 | create a function that needs to access some data which you have |
| 453 | available locally, create a new class to hold the data and return a |
| 454 | method of an instance of that class, e.g.: |
| 455 | |
| 456 | class MultiplierClass: |
| 457 | def __init__(self, factor): |
| 458 | self.factor = factor |
| 459 | def multiplier(self, argument): |
| 460 | return argument * self.factor |
| 461 | |
| 462 | def generate_multiplier(factor): |
| 463 | return MultiplierClass(factor).multiplier |
| 464 | |
| 465 | twice = generate_multiplier(2) |
| 466 | print twice(10) |
| 467 | # Output: 20 |
| 468 | |
Guido van Rossum | 2434999 | 1994-02-02 14:12:45 +0000 | [diff] [blame] | 469 | 4.6. Q. How do I iterate over a sequence in reverse order? |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 470 | |
| 471 | A. If it is a list, the fastest solution is |
| 472 | |
| 473 | list.reverse() |
| 474 | try: |
| 475 | for x in list: |
| 476 | "do something with x" |
| 477 | finally: |
| 478 | list.reverse() |
| 479 | |
| 480 | This has the disadvantage that while you are in the loop, the list |
| 481 | is temporarily reversed. If you don't like this, you can make a copy. |
| 482 | This appears expensive but is actually faster than other solutions: |
| 483 | |
| 484 | rev = list[:] |
| 485 | rev.reverse() |
| 486 | for x in rev: |
| 487 | <do something with x> |
| 488 | |
| 489 | If it isn't a list, a more general but slower solution is: |
| 490 | |
| 491 | i = len(list) |
| 492 | while i > 0: |
| 493 | i = i-1 |
| 494 | x = list[i] |
| 495 | <do something with x> |
| 496 | |
| 497 | A more elegant solution, is to define a class which acts as a sequence |
| 498 | and yields the elements in reverse order (solution due to Steve |
| 499 | Majewski): |
| 500 | |
| 501 | class Rev: |
| 502 | def __init__(self, seq): |
| 503 | self.forw = seq |
| 504 | def __len__(self): |
| 505 | return len(self.forw) |
| 506 | def __getitem__(self, i): |
| 507 | return self.forw[-(i + 1)] |
| 508 | |
| 509 | You can now simply write: |
| 510 | |
| 511 | for x in Rev(list): |
| 512 | <do something with x> |
| 513 | |
| 514 | Unfortunately, this solution is slowest of all, due the the method |
| 515 | call overhead... |
| 516 | |
Guido van Rossum | 2434999 | 1994-02-02 14:12:45 +0000 | [diff] [blame] | 517 | 4.7. Q. My program is too slow. How do I speed it up? |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 518 | |
| 519 | A. That's a tough one, in general. There are many tricks to speed up |
| 520 | Python code; I would consider rewriting parts in C only as a last |
| 521 | resort. One thing to notice is that function and (especially) method |
| 522 | calls are rather expensive; if you have designed a purely OO interface |
| 523 | with lots of tiny functions that don't do much more than get or set an |
| 524 | instance variable or call another method, you may consider using a |
| 525 | more direct way, e.g. directly accessing instance variables. Also see |
| 526 | the standard module "profile" (described in the file |
| 527 | "python/lib/profile.doc") which makes it possible to find out where |
| 528 | your program is spending most of its time (if you have some patience |
| 529 | -- the profiling itself can slow your program down by an order of |
| 530 | magnitude). |
| 531 | |
Guido van Rossum | 2434999 | 1994-02-02 14:12:45 +0000 | [diff] [blame] | 532 | 4.8. Q. When I have imported a module, then edit it, and import it |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 533 | again (into the same Python process), the changes don't seem to take |
| 534 | place. What is going on? |
| 535 | |
| 536 | A. For efficiency reasons, Python only reads the module file on the |
| 537 | first time a module is imported (otherwise a program consisting of |
| 538 | many modules, each of which imports the same basic module, would read |
| 539 | the basic module over and over again). To force a changed module |
| 540 | being read again, do this: |
| 541 | |
| 542 | import modname |
| 543 | reload(modname) |
| 544 | |
| 545 | Warning: this technique is not 100% fool-proof. In particular, |
| 546 | modules containing statements like |
| 547 | |
| 548 | from modname import some_objects |
| 549 | |
| 550 | will continue to work with the old version of the objects imported |
| 551 | thus. |
| 552 | |
Guido van Rossum | 2434999 | 1994-02-02 14:12:45 +0000 | [diff] [blame] | 553 | 4.9. Q. I have a module in which I want to execute some extra code when it |
| 554 | is run as a script. How do I find out whether I am running as a |
| 555 | script? |
| 556 | |
| 557 | A. A module can find out its own module name by alooking at the |
| 558 | (predefined) global variable __name__. If this has the value |
| 559 | '__main__' you are running as a script. E.g. if you put the following |
| 560 | on the last line of your module, main() is called only when your |
| 561 | module is running as a script: |
| 562 | |
| 563 | if __name__ == '__main__': main() |
| 564 | |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 565 | |
| 566 | 5. Extending Python |
| 567 | =================== |
| 568 | |
| 569 | 5.1. Q. Can I create my own functions in C? |
| 570 | |
| 571 | A. Yes, you can create built-in modules containing functions, |
Guido van Rossum | 2434999 | 1994-02-02 14:12:45 +0000 | [diff] [blame] | 572 | variables, exceptions and even new types in C. This is explained in |
| 573 | the document "Extending and Embedding the Python Interpreter" (the |
| 574 | LaTeX file Doc/ext.tex). Also read the chapter on dynamic loading. |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 575 | |
| 576 | 5.2. Q. Can I create my own functions in C++? |
| 577 | |
| 578 | A. Yes, using the C-compatibility features found in C++. Basically |
| 579 | you place extern "C" { ... } around the Python include files and put |
| 580 | extern "C" before each function that is going to be called by the |
| 581 | Python interpreter. Global or static C++ objects with constructors |
| 582 | are probably not a good idea. |
| 583 | |
| 584 | |
| 585 | 6. Python's design |
| 586 | ================== |
| 587 | |
| 588 | 6.1. Q. Why isn't there a generic copying operation for objects in |
| 589 | Python? |
| 590 | |
| 591 | A. Hmm. Maybe there should be one, but it's difficult to assign a |
| 592 | useful meaning to copying of open files, sockets and windows, or |
| 593 | recursive data structures. As long as you design all your classes |
| 594 | yourself you are of course free to define a standard base class that |
| 595 | defines an overridable copying operation for all the objects you care |
| 596 | about. (One practical point: it would have to be a built-in function, |
| 597 | not a standard method name, since not all built-in object types have |
| 598 | methods; e.g. strings, integers and tuples don't.) |
| 599 | |
| 600 | 6.2. Q. Why isn't there a generic way to implement persistent objects |
| 601 | in Python? (Persistent == automatically saved to and restored from |
| 602 | disk.) |
| 603 | |
| 604 | A. Hmm, hmm. Basically for the same reasons as why there is no |
| 605 | generic copying operation. |
| 606 | |
| 607 | 6.3. Q. Why isn't there a switch or case statement in Python? |
| 608 | |
| 609 | A. You can do this easily enough with a sequence of |
| 610 | if... elif... elif... else. There have been some proposals for switch |
| 611 | statement syntax, but there is no concensus (yet) on whether and how |
| 612 | to do range tests. |
| 613 | |
Guido van Rossum | c50158e | 1994-05-31 09:18:50 +0000 | [diff] [blame] | 614 | 6.4. Q. Why does Python use indentation for grouping of statements? |
| 615 | |
| 616 | A. Basically I believe that using indentation for grouping is |
| 617 | extremely elegant and contributes a lot to the clarity of the average |
| 618 | Python program. Most people learn to love this feature after a while. |
| 619 | Some arguments for it: |
| 620 | |
| 621 | - Since there are no begin/end brackets there cannot be a disagreement |
| 622 | between grouping perceived by the parser and the human reader. I |
| 623 | remember long ago seeing a C fragment like this: |
| 624 | |
| 625 | if (x <= y) |
| 626 | x++; |
| 627 | y--; |
| 628 | z++; |
| 629 | |
| 630 | and staring a long time at it wondering why y was being decremented |
| 631 | even for x > y... (And I wasn't a C newbie then either.) |
| 632 | |
| 633 | - Since there are no begin/end brackets there can be no conflicting |
| 634 | coding styles. In C there are loads of different ways to place the |
| 635 | braces (including the choice whether to place braces around single |
| 636 | statements in certain cases, for consistency). If you're used to |
| 637 | reading (and writing) code that uses one style, you will feel at least |
| 638 | slightly uneasy when reading (or being required to write) another |
| 639 | style. |
| 640 | |
| 641 | - Many coding styles place begin/end brackets on a line by themself. |
| 642 | This makes programs considerably longer and wastes valuable screen |
| 643 | space, making it harder to get a good overview over a program. |
| 644 | Ideally, a function should fit on one basic tty screen (say, 20 |
| 645 | lines). 20 lines of Python are worth a LOT more than 20 lines of C. |
| 646 | This is not solely due to the lack of begin/end brackets (the lack of |
| 647 | declarations also helps, and the powerful operations of course), but |
| 648 | it certainly helps! |
| 649 | |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 650 | |
| 651 | 7. Using Python on non-UNIX platforms |
| 652 | ===================================== |
| 653 | |
Guido van Rossum | 91f6083 | 1994-02-15 15:52:27 +0000 | [diff] [blame] | 654 | 7.1. Q. Is there a Mac version of Python? |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 655 | |
Guido van Rossum | 91f6083 | 1994-02-15 15:52:27 +0000 | [diff] [blame] | 656 | A. Yes. It is on most ftp sites carrying Python as python.sea.hqx -- |
| 657 | this is a self-extracting archive containing the application binary as |
| 658 | well as the Lib modules. |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 659 | |
Guido van Rossum | 91f6083 | 1994-02-15 15:52:27 +0000 | [diff] [blame] | 660 | 7.2. Q. Is there a DOS version of Python? |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 661 | |
Guido van Rossum | 91f6083 | 1994-02-15 15:52:27 +0000 | [diff] [blame] | 662 | A. Yes. More than one, actually: 16python.exe runs in standard DOS |
| 663 | mode on 186 CPUs or higher; 32python.exe uses a DOS extender and only |
| 664 | runs on a 386 or higher CPUs. Although 16python.exe does not pass the |
| 665 | test set because test_grammar is too big for the parser, it actually |
| 666 | has about 270 kbyte of allocatable heap space, which is sufficient for |
| 667 | fairly large programs. 32python.exe is distributed as a tar file |
| 668 | containing the required DOS extended and 387 emulator. Both are on |
| 669 | most ftp sites carrying Python. |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 670 | |
Guido van Rossum | 91f6083 | 1994-02-15 15:52:27 +0000 | [diff] [blame] | 671 | 7.3. Q. Is there a Windows version of Python? |
| 672 | |
| 673 | A. Yes. Use qwpython.exe. The only problem with it: ^C |
| 674 | unconditionally kills the entire program -- it does not raise |
| 675 | KeyboardInterrupt. You can also run 16python.exe or 32python.exe in a |
| 676 | "DOS box", but qwpython.exe appears to be slightly faster. |
| 677 | |
| 678 | 7.4. Q. Is there a Windows NT version of Python? |
| 679 | |
| 680 | A. Yes. Use ntpython.exe. This is for Intel CPUs. If you want a |
| 681 | Windows user interface, use qwpython.exe. |
| 682 | |
| 683 | 7.5. Q. I have the DOS or Windows version but it appears to be only a |
| 684 | binary. Where's the library? |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 685 | |
| 686 | A. You still need to copy the files from the distribution directory |
Guido van Rossum | 91f6083 | 1994-02-15 15:52:27 +0000 | [diff] [blame] | 687 | "python/Lib" to your system. If you don't have the full distribution, |
Guido van Rossum | 44b4cb1 | 1994-05-04 13:28:51 +0000 | [diff] [blame] | 688 | you can get the file pythonlib1.0.2.tar.gz from most ftp sites carrying |
Guido van Rossum | 91f6083 | 1994-02-15 15:52:27 +0000 | [diff] [blame] | 689 | Python; this is a subset of the distribution containing just those |
| 690 | file. |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 691 | |
Guido van Rossum | 5333c5d | 1994-04-11 11:06:22 +0000 | [diff] [blame] | 692 | Once you have installed the library, you need to point sys.path to it. |
| 693 | Assuming the library is in C:\misc\python\lib, the following commands |
| 694 | will point your Python interpreter to it (note the doubled backslashes |
| 695 | -- you can also use single forward slashes instead): |
| 696 | |
| 697 | >>> import sys |
| 698 | >>> sys.path.insert(0, 'C:\\misc\\python\\lib') |
| 699 | >>> |
| 700 | |
| 701 | For a more permanent effect, set the environment variable PYTHONPATH, |
| 702 | as follows (talking to a DOS prompt): |
| 703 | |
| 704 | C> SET PYTHONPATH=C:\misc\python\lib |
| 705 | |
Guido van Rossum | 91f6083 | 1994-02-15 15:52:27 +0000 | [diff] [blame] | 706 | 7.6. Q. Where's the documentation for the Mac or PC version? |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 707 | |
| 708 | A. There isn't any. The documentation for the Unix version also |
Guido van Rossum | 91f6083 | 1994-02-15 15:52:27 +0000 | [diff] [blame] | 709 | applies to the Mac and PC versions. Where applicable, differences |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 710 | are indicated in the text. |
| 711 | |
Guido van Rossum | 91f6083 | 1994-02-15 15:52:27 +0000 | [diff] [blame] | 712 | 7.7. Q. The Mac (PC) version doesn't seem to have any facilities for |
| 713 | creating or editing programs apart from entering it interactively, and |
| 714 | there seems to be no way to save code that was entered interactively. |
| 715 | How do I create a Python program on the Mac (PC)? |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 716 | |
Guido van Rossum | 91f6083 | 1994-02-15 15:52:27 +0000 | [diff] [blame] | 717 | A. Use an external editor. On the Mac, I am quite happy with the Desk |
| 718 | Accessory called Sigma Edit; this doesn't require Multifinder or |
| 719 | System 7. I work like this: start the interpreter; edit a module file |
| 720 | using Sigma Edit; import and test it in the interpreter; edit again in |
| 721 | Sigma Edit; then use the built-in function reload() to re-read the |
| 722 | imported module; etc. |
Guido van Rossum | 5333c5d | 1994-04-11 11:06:22 +0000 | [diff] [blame] | 723 | |
| 724 | Regarding the same question for the PC, Kurt Wm. Hemr writes: "While |
| 725 | anyone with a pulse could certainly figure out how to do the same on |
| 726 | MS-Windows, I would recommend the NotGNU Emacs clone for MS-Windows. |
| 727 | Not only can you easily resave and "reload()" from Python after making |
| 728 | changes, but since WinNot auto-copies to the clipboard any text you |
| 729 | select, you can simply select the entire procedure (function) which |
| 730 | you changed in WinNot, switch to QWPython, and shift-ins to reenter |
| 731 | the changed program unit." |