Python on MacOS Systems
It is no big surprise that Python has a standard port for Macintoshes because Python itself was created on a Macintosh. This port is called MacPython and is maintained by Jack Jansen. MacPython applies to MacOS up to version 9. Installing Python on MacOS X (10) systems will be much more like a standard UNIX installation.
Python runs great on Apple Macintoshes, iMacs, iBooks, and so forth. Note that you can decide whether you want to install Python under the MacOS (using the MacPython distribution), under a Linux installation (in case you are using a distribution such as the Yellow Dog), or even under Java (using JPython, the Python interpreter written in Java). If you have Linux installed on your Mac, it is best for you to look at the UNIX section.
At this moment, the current stable distribution is 1.5.2. For this release, the installer is available in two forms: MacBinary format and BinHex format. It is suggested that the latter option should be used in case your browser mistreats MacBinary files. The installer can also install some optional extensions for you, including Tkinter, the Numerical, and Imaging modules.
Also included in the distribution (and optionally installed by the installer) is an integrated development environment written by Just van Rossum (Guido's brother), which includes an editor, debugger, and class browser.
The MacPython distribution contains the same set of extension modules that is available for almost every platform (sys,
string,
time, and so on). Besides that, it contains a set of modules that provide interfaces to specific MacOS services, including access to QuickTime and QuickDraw.
In order to download Python for Macintosh, the source code, and all the available documentation, check out Jack Jansen's MacPython Web page at
http://www.cwi.nl/~jack/macpython.html
The most noticeable differences between MacPython and the UNIX/Windows distributions are the following:
It doesn't provide access to the standard POSIX features (pipes, forking, access to command-line interfaces, and so on). In particular, looking at the Mac module, you'll see what functions you can expect in the os module. If you compare this to the posix or winnt module, you'll see what is missing: Options like posix.fork are not available on the Mac.
The threading mechanism is just starting to show up now (with Python 2.0), as the most recent versions of the GUSI development environment for MacOS support POSIX threads. Note that threading support using the user-space GNU pth library was also added to the language in the release 2.0. Consequently, now you have the option to run programs on Macintosh that are able to use Python's POSIX threading support.
Tkinter works, but not as smoothly as it could. It is expected that when 1.6 binaries come out, things should be much better.
Support for C extension modules is based on patches because most of them are written for UNIX or Windows.
Porting a Python application from other systems to MacPython works fine, assuming it has been written in a cross-platform way.
Precise details on the differences in the standard distribution can be found in the Python Documentationif a module or feature is not compatible with the Mac distribution, it will say so there. For more technical details, you might want to join the PythonMac SIG, which has discussions on Macintosh-specific aspects of Python. Check out
http://www.python.org/sigs/pythonmac-sig/
The official documentation for the Macintosh specific modules available in the MacPython distribution is located at
http://www.python.org/doc/current/mac/mac.html
Next, I list the description of those modules.
mac
This module implements the operating system dependent functionality provided by the standard module os. Note that it is best used when accessed through the os module.
macpath
This module is the Macintosh implementation of the os.path module.
Caution
You shouldn't try to use the previous two modules directly. Instead, use the os module.
ctb
This module provides a partial interface to the Macintosh Communications Toolbox. Currently, only Connection Manager tools are supported. It might not be available in all MacPython versions.
macconsole
This module is available on the Macintosh, provided Python has been built using the Think C compiler. It provides an interface to the Think console package, with which basic text windows can be created.
macdnr
This module provides an interface to the Macintosh Domain Name Resolver. It is usually used in conjunction with the mactcp module, to map hostnames to IP addresses. It might not be available in all MacPython versions.
macfs
This module provides support for Macintosh FSSpec handling, the Alias Manager, finder aliases, and the Standard File package.
ic
This module provides access to Macintosh Internet Config package, which stores preferences for Internet programs such as mail address, default homepage, and so on. Also, Internet Config contains an elaborate set of mappings from Macintosh creator/type codes to foreign filename extensions plus information on how to transfer files (binary, ascii, and so on).
MacOS
This module provides access to MacOS specific interpreter features, such as how the interpreter eventloop functions and the like. It is suggested that you use this module with care.
macostools
This module contains some convenience routines for file manipulation on the Macintosh.
findertools
This module provides wrapper routines around the finder's Apple Events interface.
mactcp
This module provides an interface to the Macintosh TCP/IP driver (MacTCP). There is an accompanying module, macdnr, which provides an interface to the name server (allowing you to translate hostnames to IP addresses), and a module MACTCPconst that has symbolic names for constants used by MacTCP. Note that because the built-in module socket is also available on the Macintosh, it is usually easier to use sockets instead of the Macintosh-specific MacTCP API.
macspeech
This module provides an interface to the Macintosh Speech Manager, allowing you to let the Macintosh utter phrases. You need a version of the Speech Manager extension (version 1 and 2 have been tested) in your Extensions folder for this to work. The module does not provide full access to all features of the Speech Manager yet. It might not be available in all MacPython versions.
EasyDialogs
The EasyDialogs module contains some basic dialogs for the Macintosh, modeled after the stdwin dialogs with similar names.
FrameWork
The FrameWork module contains classes that together provide a framework for an interactive Macintosh application. The programmer builds an application by creating subclasses that override various methods of the bases classes, thereby implementing the functionality wanted. Overriding functionality can often be done on various different levels. For instance, to handle clicks in a single dialog window in a non-standard way, it is not necessary to override the complete event handling.
MiniAEFrame
The module MiniAEFrame provides a framework for an application that can function as an Open Scripting Architecture (OSA) server, that is receive and process AppleEvents. It can be used in conjunction with FrameWork or standalone. This module is temporary; it will eventually be replaced by a module that handles argument names better and possibly automates making your application scriptable.
This Open Directory page provides many links for materials about MacPython available on the Web:
http://dmoz.org/Computers/Systems/Macintosh/Development/Languages/Python/