Archive for October 2004
Python IDLE with “new” division on OS X
2004-10-05 22:08(Deutscher Text siehe separater Artikel)
Kamen got the book Python für Kids. To enable him to use the book on OS X, I wanted to setup the Python environment on the Mac as on the PC: Install IDLE and, to hide the differences between integer and floating point math, configure to use the new division.
Installing IDLE on OS X 10.3 is easy with MacPython. IDLE comes as bundle, ready to be launched with the mouse from the Finder. But for using the new division without the need for from __future__ import division, IDLE must be started with options. How to embed these options in the IDLE.app bundle?
With the help of Jack Jansen and Andreas Glenn from the pythonmac-sig, I found out how:
- Use the Finder to make a backup copy of
/Applications/MacPython-2.3/IDLE, just in case you get
something wrong - Open /Applications/MacPython-2.3/IDLE.app/Contents/MacOS/IDLE
in your favourite editor - Insert two lines after the first sys.argv.insert line. It
should look like this:
sys.argv.insert(1, mainprogram) sys.argv.insert(1, "-Qnew") sys.argv.append("-n")
That’s it! You can launch IDLE from the Finder and verify that 5/2 equals 2.5

Python für Kids auf dem Macintosh
2004-10-05 22:08Im Gegensatz zu PCs ist bei OS X Python bereits vorinstalliert. Leider fehlt jedoch ausgerechnet IDLE, so dass trotzdem noch etwas zu tun bleibt.
Installationsanleitung für IDLE (von PythonMac FAQ abgekupfert):
- Tcl/Tk Aqua herunterladen und installieren
- MacPython herunterladen und installieren (für OS X 10.3 sind das die MacPython Panther Addons)
- Das Programm PackageManager im Ordner /Programme/MacPython-2.3 starten
- Im PackageManager _tkinter installieren
“Neue” Division
Damit IDLE sich so benimmt wie im Buch beschrieben (vgl. Anhang D im Buch), muss noch eine Datei leicht verändert werden.
- Kopiere die Applikation /Programme/MacPython-2.3/IDLE (falls irgendetwas schief geht)
- Starte IDLE (oder einen anderen Editor)
- Öffne /Programme/MacPython-2.3/IDLE.app/Contents/MacOS/IDLE: Im üblichen Öffnen-Dialog Shift-Cmd-G drücken — es erscheint ein Feld “Go to the Folder” — und hier /Applications/MacPython-2.3/IDLE.app/Contents/MacOS eingeben: jetzt kann die Datei IDLE ausgewählt und geöffnet werden
- Nach der sys.argv.insert Zeile zwei zusätzliche Zeilen eingeben. Die Datei sollte danach ausschnittsweise so aussehen:
sys.argv.insert(1, mainprogram)
sys.argv.insert(1, "-Qnew")
sys.argv.append("-n")

Einstellungen
Die Tastenbelegung sollte noch angepasst werden, damit frühere Anweisungen in die Eingabezeile zurückgerufen werden können (vgl. den “Möhren-Absatz” auf Seite 51). Dazu muss im Options-Menu von IDLE der Dialog Configure IDLE… aufgerufen werden:

Auf der Dialog-Seite Keys sollte IDLE Classic Mac ausgewählt werden; dann funktioniert das Blättern in früheren Anweisungen mit Ctrl-P und Ctrl-N.