2.2.6 Sequence Types

typeiter.html | types.html | string-methods.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
2.2.5 Iterator Types (typeiter.html)
Up:
2.2 Built-in Types (types.html)
Next:
2.2.6.1 String Methods (string-methods.html)
---
## 2.2.6 Sequence Types
There are six sequence types: strings, Unicode strings, lists,
tuples, buffers, and xrange objects.
String literals are written in single or double quotes:
`'xyzzy'`, `"frobozz"`. See chapter 2 of the
Python Reference Manual (../ref/strings.html) for more about
string literals. Unicode strings are much like strings, but are
specified in the syntax using a preceeding "u" character:
`u'abc'`, `u"def"`. Lists are constructed with square brackets,
separating items with commas: `[a, b, c]`. Tuples are
constructed by the comma operator (not within square brackets), with
or without enclosing parentheses, but an empty tuple must have the
enclosing parentheses, e.g., `a, b, c` or `()`. A single
item tuple must have a trailing comma, e.g., `(d,)`.
Buffer objects are not directly supported by Python syntax, but can be
created by calling the builtin function
buffer(). They don't support
concatenation or repetition.
Xrange objects are similar to buffers in that there is no specific
syntax to create them, but they are created using the xrange()
function. They don't support slicing,
concatenation or repetition, and using `in`, `not in`,
min() or max() on them is inefficient.
Most sequence types support the following operations. The "in" and
"not in" operations have the same priorities as the comparison
operations. The "+" and "*" operations have the same
priority as the corresponding numeric operations.2.7 (#foot1788)
This table lists the sequence operations sorted in ascending priority
(operations in the same box have the same priority). In the table,
s and t are sequences of the same type; n, i
and j are integers:
Notes:
(1): When s is a string or Unicode string object the
`in` and `not in` operations act like a substring test. In
Python versions before 2.3, x had to be a string of length 1.
In Python 2.3 and beyond, x may be a string of any length.
(2): Values of n less than `0` are treated as
`0` (which yields an empty sequence of the same type as
s). Note also that the copies are shallow; nested structures
are not copied. This often haunts new Python programmers; consider:
```text

>>> lists = [[]] * 3
>>> lists
[[], [], []]
>>> lists[0].append(3)
>>> lists
[[3], [3], [3]]
```
What has happened is that `lists` is a list containing three
copies of the list `[[]]` (a one-element list containing an
empty list), but the contained list is shared by each copy. You can
create a list of different lists this way:
```text

>>> lists = [[] for i in range(3)]
>>> lists[0].append(3)
>>> lists[1].append(5)
>>> lists[2].append(7)
>>> lists
[[3], [5], [7]]
```
(3): If i or j is negative, the index is relative to
the end of the string: `len( s ) + i` or
`len( s ) + j` is substituted. But note that `-0` is
still `0`.
(4): The slice of s from i to j is defined as
the sequence of items with index k such that `i <= k < j`. If i or j is greater than
`len( s )`, use `len( s )`. If i is omitted,
use `0`. If j is omitted, use `len( s )`. If
i is greater than or equal to j, the slice is empty.
(5): The slice of s from i to j with step
k is defined as the sequence of items with index
`x = i + n * k` such that `0`
`<=` n `<` `abs(i-j)`. If i or j
is greater than `len( s )`, use `len( s )`. If
i or j are ommitted then they become ``end'' values
(which end depends on the sign of k).
---
#### Footnotes
... operations.2.7 (typesseq.html#tex2html8): They must
have since the parser can't tell the type of the operands.


A. Undocumented Modules

module-winsound.html | lib.html | node744.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
22.3 winsound (module-winsound.html)
Up:
Python Library Reference (lib.html)
Next:
A.1 Frameworks (node744.html)
---
# A. Undocumented Modules
Here's a quick listing of modules that are currently undocumented, but
that should be documented. Feel free to contribute documentation for
them! (Send via email to python-docs@python.org.)
The idea and original contents for this chapter were taken
from a posting by Fredrik Lundh; the specific contents of this chapter
have been substantially revised.


5.3.4 Classes and functions

legacy-unit-tests.html | module-unittest.html | testcase-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
5.3.3 Re-using old test (legacy-unit-tests.html)
Up:
5.3 unittest (module-unittest.html)
Next:
5.3.5 TestCase Objects (testcase-objects.html)
---
## 5.3.4 Classes and functions


testloader-objects.html | module-unittest.html | module-test.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
5.3.8 TestLoader Objects (testloader-objects.html)
Up:
5.3 unittest (module-unittest.html)
Next:
5.4 test (module-test.html)
---
## 5.3.9 Getting Extended Error Information
Some applications can make use of more error information (for example,
an integrated development environment, or IDE). Such an application
can retrieve supplemental information about errors and failures by
using an alternate TestResult implementation, and extending
the defaultTestResult() method of the TestCase class
to provide it.
Here is a brief example of a TestResult subclass which stores
the actual exception and traceback objects. (Be aware that storing
traceback objects can cause a great deal of memory not to be reclaimed
when it otherwise would be, which can have effects that affect the
behavior of the tests.)
```text

import unittest

class MyTestCase(unittest.TestCase):
def defaultTestResult(self):
return MyTestResult()

class MyTestResult(unittest.TestResult):
def __init__(self):
self.errors_tb = []
self.failures_tb = []

def addError(self, test, err):
self.errors_tb.append((test, err))
unittest.TestResult.addError(self, test, err)

def addFailure(self, test, err):
self.failures_tb.append((test, err))
unittest.TestResult.addFailure(self, test, err)
```


8. Unix Specific Services

completer-objects.html | lib.html | module-posix.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
7.21.1 Completer Objects (completer-objects.html)
Up:
Python Library Reference (lib.html)
Next:
8.1 posix (module-posix.html)
---
# 8. Unix Specific Services
The modules described in this chapter provide interfaces to features
that are unique to the Unix operating system, or in some cases to
some or many variants of it. Here's an overview:


11.5.19 UnknownHandler Objects

gopher-handler.html | module-urllib2.html | urllib2-examples.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
11.5.18 GopherHandler Objects (gopher-handler.html)
Up:
11.5 urllib2 (module-urllib2.html)
Next:
11.5.20 Examples (urllib2-examples.html)
---
## 11.5.19 UnknownHandler Objects


11.5.20 Examples

unknown-handler-objects.html | module-urllib2.html | module-httplib.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
11.5.19 UnknownHandler Objects (unknown-handler-objects.html)
Up:
11.5 urllib2 (module-urllib2.html)
Next:
11.6 httplib (module-httplib.html)
---
## 11.5.20 Examples
This example gets the python.org main page and displays the first 100
bytes of it:
```text

>>> import urllib2
>>> f = urllib2.urlopen('http://www.python.org/')
>>> print f.read(100)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<?xml-stylesheet href="./css/ht2html
```
Here we are sending a data-stream to the stdin of a CGI and reading
the data it returns to us:
```text

>>> import urllib2
>>> req = urllib2.Request(url='https://localhost/cgi-bin/test.cgi',
... data='This data is passed to stdin of the CGI')
>>> f = urllib2.urlopen(req)
>>> print f.read()
Got Data: "This data is passed to stdin of the CGI"
```
The code for the sample CGI used in the above example is:


11.4.1 URLopener Objects

module-urllib.html | module-urllib.html | node415.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
11.4 urllib (module-urllib.html)
Up:
11.4 urllib (module-urllib.html)
Next:
11.4.2 Examples (node415.html)
---
## 11.4.1 URLopener Objects
URLopener and FancyURLopener objects have the
following attributes.
The FancyURLopener class offers one additional method that
should be overloaded to provide the appropriate behavior:


3.20.1 Warning Categories

module-warnings.html | module-warnings.html | warning-filter.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
3.20 warnings (module-warnings.html)
Up:
3.20 warnings (module-warnings.html)
Next:
3.20.2 The Warnings Filter (warning-filter.html)
---
## 3.20.1 Warning Categories
There are a number of built-in exceptions that represent warning
categories. This categorization is useful to be able to filter out
groups of warnings. The following warnings category classes are
currently defined:
While these are technically built-in exceptions, they are documented
here, because conceptually they belong to the warnings mechanism.
User code can define additional warning categories by subclassing one
of the standard warning categories. A warning category must always be
a subclass of the Warning class.


3.20.2 The Warnings Filter

warning-categories.html | module-warnings.html | warning-functions.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
3.20.1 Warning Categories (warning-categories.html)
Up:
3.20 warnings (module-warnings.html)
Next:
3.20.3 Available Functions (warning-functions.html)
---
## 3.20.2 The Warnings Filter
The warnings filter controls whether warnings are ignored, displayed,
or turned into errors (raising an exception).
Conceptually, the warnings filter maintains an ordered list of filter
specifications; any specific warning is matched against each filter
specification in the list in turn until a match is found; the match
determines the disposition of the match. Each entry is a tuple of the
form (action, message, category, module,
lineno), where:
- action is one of the following strings:
- message is a string containing a regular expression that
the warning message must match (the match is compiled to always be
case-insensitive)
- category is a class (a subclass of Warning) of
which the warning category must be a subclass in order to match
- module is a string containing a regular expression that the module
name must match (the match is compiled to be case-sensitive)
- lineno is an integer that the line number where the
warning occurred must match, or `0` to match all line
numbers
Since the Warning class is derived from the built-in
Exception class, to turn a warning into an error we simply
raise `category(message)`.
The warnings filter is initialized by -W options passed
to the Python interpreter command line. The interpreter saves the
arguments for all -W options without interpretation in
`sys.warnoptions`; the warnings module parses these when
it is first imported (invalid options are ignored, after printing a
message to `sys.stderr`).


3.20.3 Available Functions

warning-filter.html | module-warnings.html | module-imp.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
3.20.2 The Warnings Filter (warning-filter.html)
Up:
3.20 warnings (module-warnings.html)
Next:
3.21 imp (module-imp.html)
---
## 3.20.3 Available Functions


14.5.1 Wave_read Objects

module-wave.html | module-wave.html | Wave-write-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
14.5 wave (module-wave.html)
Up:
14.5 wave (module-wave.html)
Next:
14.5.2 Wave_write Objects (Wave-write-objects.html)
---
## 14.5.1 Wave_read Objects
Wave_read objects, as returned by open(), have the
following methods:
The following two methods are defined for compatibility with the
aifc (module-aifc.html) module, and don't do anything interesting.
The following two methods define a term ``position'' which is compatible
between them, and is otherwise implementation dependent.


14.5.2 Wave_write Objects

Wave-read-objects.html | module-wave.html | module-chunk.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
14.5.1 Wave_read Objects (Wave-read-objects.html)
Up:
14.5 wave (module-wave.html)
Next:
14.6 chunk (module-chunk.html)
---
## 14.5.2 Wave_write Objects
Wave_write objects, as returned by open(), have the
following methods:


3.3.2 Example

weakref-objects.html | module-weakref.html | weakref-extension.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
3.3.1 Weak Reference Objects (weakref-objects.html)
Up:
3.3 weakref (module-weakref.html)
Next:
3.3.3 Weak References in (weakref-extension.html)
---
## 3.3.2 Example
This simple example shows how an application can use objects IDs to
retrieve objects that it has seen before. The IDs of the objects can
then be used in other data structures without forcing the objects to
remain alive, but the objects can still be retrieved by ID if they
do.
```text

import weakref

_id2obj_dict = weakref.WeakValueDictionary()

def remember(obj):
oid = id(obj)
_id2obj_dict[oid] = obj
return oid

def id2obj(oid):
return _id2obj_dict[oid]
```


weakref-example.html | module-weakref.html | module-fpectl.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
3.3.2 Example (weakref-example.html)
Up:
3.3 weakref (module-weakref.html)
Next:
3.4 fpectl (module-fpectl.html)
---
## 3.3.3 Weak References in Extension Types
One of the goals of the implementation is to allow any type to
participate in the weak reference mechanism without incurring the
overhead on those objects which do not benefit by weak referencing
(such as numbers).
For an object to be weakly referencable, the extension must include a
PyObject* field in the instance structure for the use of the
weak reference mechanism; it must be initialized to NULL by the
object's constructor. It must also set the tp_weaklistoffset
field of the corresponding type object to the offset of the field.
Also, it needs to add Py_TPFLAGS_HAVE_WEAKREFS to the
tp_flags slot. For example, the instance type is defined with the
following structure:
```text

typedef struct {
PyObject_HEAD
PyClassObject *in_class; /* The class object */
PyObject *in_dict; /* A dictionary */
PyObject *in_weakreflist; /* List of weak references */
} PyInstanceObject;
```
The statically-declared type object for instances is defined this way:
```text

PyTypeObject PyInstance_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0,
"module.instance",

/* Lots of stuff omitted for brevity... */

Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_WEAKREFS /* tp_flags */
0, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
offsetof(PyInstanceObject, in_weakreflist), /* tp_weaklistoffset */
};
```
The type constructor is responsible for initializing the weak reference
list to NULL:
```text

static PyObject *
instance_new() {
/* Other initialization stuff omitted for brevity */

self->in_weakreflist = NULL;

return (PyObject *) self;
}
```
The only further addition is that the destructor needs to call the
weak reference manager to clear any weak references. This should be
done before any other parts of the destruction have occurred, but is
only required if the weak reference list is non-NULL:


3.3.1 Weak Reference Objects

module-weakref.html | module-weakref.html | weakref-example.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
3.3 weakref (module-weakref.html)
Up:
3.3 weakref (module-weakref.html)
Next:
3.3.2 Example (weakref-example.html)
---
## 3.3.1 Weak Reference Objects
Weak reference objects have no attributes or methods, but do allow the
referent to be obtained, if it still exists, by calling it:
```text

>>> import weakref
>>> class Object:
... pass
...
>>> o = Object()
>>> r = weakref.ref(o)
>>> o2 = r()
>>> o is o2
1
```
If the referent no longer exists, calling the reference object returns
`None`:
```text

>>> del o, o2
>>> print r()
None
```
Testing that a weak reference object is still live should be done
using the expression `ref () is not None`. Normally,
application code that needs to use a reference object should follow
this pattern:
```text

# r is a weak reference object
o = r()
if o is None:
# referent has been garbage collected
print "Object has been allocated; can't frobnicate."
else:
print "Object is still live!"
o.do_something_useful()
```
Using a separate test for ``liveness'' creates race conditions in
threaded applications; another thread can cause a weak reference to
become invalidated before the weak reference is called; the
idiom shown above is safe in threaded applications as well as
single-threaded applications.


12.1.4 Writer Implementations

writer-interface.html | module-formatter.html | module-email.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
12.1.3 The Writer Interface (writer-interface.html)
Up:
12.1 formatter (module-formatter.html)
Next:
12.2 email (module-email.html)
---
## 12.1.4 Writer Implementations
Three implementations of the writer object interface are provided as
examples by this module. Most applications will need to derive new
writer classes from the NullWriter class.


12.1.3 The Writer Interface

formatter-impls.html | module-formatter.html | writer-impls.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
12.1.2 Formatter Implementations (formatter-impls.html)
Up:
12.1 formatter (module-formatter.html)
Next:
12.1.4 Writer Implementations (writer-impls.html)
---
## 12.1.3 The Writer Interface
Interfaces to create writers are dependent on the specific writer
class being instantiated. The interfaces described below are the
required interfaces which all writers must support once initialized.
Note that while most applications can use the
AbstractFormatter class as a formatter, the writer must
typically be provided by the application.


module-test.testsupport.html | module-test.html | regrtest.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
5.4.1 [test.testsupport]test.test_support (module-test.testsupport.html)
Up:
5.4 test (module-test.html)
Next:
5.4.3 Running tests Using (regrtest.html)
---
## 5.4.2 Writing Unit Tests for the test package
It is preferred that tests for the test package use the
unittest (module-unittest.html) module and follow a few guidelines.
One is to have the name of all the test methods start with `"test_"` as
well as the module's name.
This is needed so that the methods are recognized by the test driver as
test methods.
Also, no documentation string for the method should be included.
A comment (such as
`# Tests function returns only True or False`) should be used to provide
documentation for test methods.
This is done because documentation strings get printed out if they exist and
thus what test is being run is not stated.
A basic boilerplate is often used:
```text

import unittest
from test import test_support

class MyTestCase1(unittest.TestCase):

# Only use setUp() and tearDown() if necessary

def setUp(self):
... code to execute in preparation for tests ...

def tearDown(self):
... code to execute to clean up after tests ...

def test_feature_one(self):
# Test feature one.
... testing code ...

def test_feature_two(self):
# Test feature two.
... testing code ...

... more test methods ...

class MyTestCase2(unittest.TestCase):
... same structure as MyTestCase1 ...

... more test classes ...

def test_main():
test_support.run_unittest(MyTestCase1,
MyTestCase2,
... list other tests ...
)

if __name__ == '__main__':
test_main()
```
This boilerplate code allows the testing suite to be run by regrtest.py
as well as on its own as a script.
The goal for regression testing is to try to break code.
This leads to a few guidelines to be followed:
- The testing suite should exercise all classes, functions, and
constants.
This includes not just the external API that is to be presented to the
outside world but also "private" code.
- Whitebox testing (examining the code being tested when the tests are
being written) is preferred.
Blackbox testing (testing only the published user interface) is not
complete enough to make sure all boundary and edge cases are tested.
- Make sure all possible values are tested including invalid ones.
This makes sure that not only all valid values are acceptable but also
that improper values are handled correctly.
- Exhaust as many code paths as possible.
Test where branching occurs and thus tailor input to make sure as many
different paths through the code are taken.
- Add an explicit test for any bugs discovered for the tested code.
This will make sure that the error does not crop up again if the code is
changed in the future.
- Make sure to clean up after your tests (such as close and remove all
temporary files).
- Import as few modules as possible and do it as soon as possible.
This minimizes external dependencies of tests and also minimizes possible
anomalous behavior from side-effects of importing a module.
- Try to maximize code reuse.
On occasion tests will vary by something as small as what type of input
they take.
Minimize code duplication by subclassing a basic test class with a class
that specifies the input:
```text

class TestFuncAcceptsSequences(unittest.TestCase):

func = mySuperWhammyFunction

def test_func(self):
self.func(self.arg)

class AcceptLists(TestFuncAcceptsSequences):
arg = [1,2,3]

class AcceptStrings(TestFuncAcceptsSequences):
arg = 'abc'

class AcceptTuples(TestFuncAcceptsSequences):
arg = (1,2,3)
```
See Also:


12.17.3 Exceptions

xdr-unpacker-objects.html | module-xdrlib.html | module-netrc.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
12.17.2 Unpacker Objects (xdr-unpacker-objects.html)
Up:
12.17 xdrlib (module-xdrlib.html)
Next:
12.18 netrc (module-netrc.html)
---
## 12.17.3 Exceptions
Exceptions in this module are coded as class instances:
Here is an example of how you would catch one of these exceptions:
```text

import xdrlib
p = xdrlib.Packer()
try:
p.pack_double(8.01)
except xdrlib.ConversionError, instance:
print 'packing the double failed:', instance.msg
```


12.17.1 Packer Objects

module-xdrlib.html | module-xdrlib.html | xdr-unpacker-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
12.17 xdrlib (module-xdrlib.html)
Up:
12.17 xdrlib (module-xdrlib.html)
Next:
12.17.2 Unpacker Objects (xdr-unpacker-objects.html)
---
## 12.17.1 Packer Objects
Packer instances have the following methods:
In general, you can pack any of the most common XDR data types by
calling the appropriate `pack_ type ()` method. Each method
takes a single argument, the value to pack. The following simple data
type packing methods are supported: pack_uint(),
pack_int(), pack_enum(), pack_bool(),
pack_uhyper(), and pack_hyper().
The following methods support packing strings, bytes, and opaque data:
The following methods support packing arrays and lists:


12.17.2 Unpacker Objects

xdr-packer-objects.html | module-xdrlib.html | xdr-exceptions.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
12.17.1 Packer Objects (xdr-packer-objects.html)
Up:
12.17 xdrlib (module-xdrlib.html)
Next:
12.17.3 Exceptions (xdr-exceptions.html)
---
## 12.17.2 Unpacker Objects
The Unpacker class offers the following methods:
In addition, every data type that can be packed with a Packer,
can be unpacked with an Unpacker. Unpacking methods are of the
form `unpack_ type ()`, and take no arguments. They return the
unpacked object.
In addition, the following methods unpack strings, bytes, and opaque
data:
The following methods support unpacking arrays and lists:


13.13.1 XML Namespaces

module-xmllib.html | module-xmllib.html | mmedia.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
13.13 xmllib (module-xmllib.html)
Up:
13.13 xmllib (module-xmllib.html)
Next:
14. Multimedia Services (mmedia.html)
---
## 13.13.1 XML Namespaces
This module has support for XML namespaces as defined in the XML
Namespaces proposed recommendation.
Tag and attribute names that are defined in an XML namespace are
handled as if the name of the tag or element consisted of the
namespace (the URL that defines the namespace) followed by a
space and the name of the tag or attribute. For instance, the tag
`<html xmlns='http://www.w3.org/TR/REC-html40'>` is treated as if
the tag name was `'http://www.w3.org/TR/REC-html40 html'`, and
the tag `<html:a href='http://frob.com'>` inside the above
mentioned element is treated as if the tag name were
`'http://www.w3.org/TR/REC-html40 a'` and the attribute name as
if it were `'http://www.w3.org/TR/REC-html40 href'`.
An older draft of the XML Namespaces proposal is also recognized, but
triggers a warning.
See Also:


13.5.1 XMLParser Objects

module-xml.parsers.expat.html | module-xml.parsers.expat.html | expaterror-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
13.5 xml.parsers.expat (module-xml.parsers.expat.html)
Up:
13.5 xml.parsers.expat (module-xml.parsers.expat.html)
Next:
13.5.2 ExpatError Exceptions (expaterror-objects.html)
---
## 13.5.1 XMLParser Objects
xmlparser objects have the following methods:
xmlparser objects have the following attributes:
The following attributes contain values relating to the most recent
error encountered by an xmlparser object, and will only have
correct values once a call to Parse() or ParseFile()
has raised a xml.parsers.expat.ExpatError exception.
Here is the list of handlers that can be set. To set a handler on an
xmlparser object o, use
`o . handlername = func`. handlername must
be taken from the following list, and func must be a callable
object accepting the correct number of arguments. The arguments are
all strings, unless otherwise stated.


13.12.1 XMLReader Objects

module-xml.sax.xmlreader.html | module-xml.sax.xmlreader.html | incremental-parser-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
13.12 xml.sax.xmlreader (module-xml.sax.xmlreader.html)
Up:
13.12 xml.sax.xmlreader (module-xml.sax.xmlreader.html)
Next:
13.12.2 IncrementalParser Objects (incremental-parser-objects.html)
---
## 13.12.1 XMLReader Objects
The XMLReader interface supports the following methods:


11.20.8 Example of Client Usage

node474.html | module-xmlrpclib.html | module-SimpleXMLRPCServer.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
11.20.7 Convenience Functions (node474.html)
Up:
11.20 xmlrpclib (module-xmlrpclib.html)
Next:
11.21 SimpleXMLRPCServer (module-SimpleXMLRPCServer.html)
---
## 11.20.8 Example of Client Usage


7.18.1 ZipFile Objects

module-zipfile.html | module-zipfile.html | pyzipfile-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
7.18 zipfile (module-zipfile.html)
Up:
7.18 zipfile (module-zipfile.html)
Next:
7.18.2 PyZipFile Objects (pyzipfile-objects.html)
---
## 7.18.1 ZipFile Objects
The following data attribute is also available:


7.18.3 ZipInfo Objects

pyzipfile-objects.html | module-zipfile.html | module-tarfile.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
7.18.2 PyZipFile Objects (pyzipfile-objects.html)
Up:
7.18 zipfile (module-zipfile.html)
Next:
7.19 tarfile (module-tarfile.html)
---
## 7.18.3 ZipInfo Objects
Instances of the ZipInfo class are returned by the
getinfo() and infolist() methods of
ZipFile objects. Each object stores information about a
single member of the ZIP archive.
Instances have the following attributes:


About this document ...

genindex.html | mac.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
Up:
Macintosh Library Modules (mac.html)
---
# About this document ...
Macintosh Library Modules,
July 29, 2003, Release 2.3
This document was generated using the LaTeX2HTML (http://saftsack.fs.uni-bayreuth.de/~latex2ht/) translator.
LaTeX2HTML (http://saftsack.fs.uni-bayreuth.de/~latex2ht/) is Copyright ©
1993, 1994, 1995, 1996, 1997, Nikos
Drakos (http://cbl.leeds.ac.uk/nikos/personal.html), Computer Based Learning Unit, University of
Leeds, and Copyright © 1997, 1998, Ross
Moore (http://www.maths.mq.edu.au/~ross/), Mathematics Department, Macquarie University,
Sydney.
The application of LaTeX2HTML (http://saftsack.fs.uni-bayreuth.de/~latex2ht/) to the Python
documentation has been heavily tailored by Fred L. Drake,
Jr. Original navigation icons were contributed by Christopher
Petrilli.
---
## Comments and Questions
General comments and questions regarding this document should
be sent by email to python-docs@python.org (mailto:python-docs@python.org). If you find specific errors in
this document, either in the content or the presentation, please
report the bug at the Python Bug
Tracker (http://sourceforge.net/bugs/?group_id=5470) at SourceForge (http://sourceforge.net/).
Questions regarding how to use the information in this
document should be sent to the Python news group, comp.lang.python (news:comp.lang.python), or the Python mailing list (http://www.python.org/mailman/listinfo/python-list) (which is gated to the newsgroup and
carries the same content).
For any of these channels, please be sure not to send HTML email.
Thanks.


3.5.1 AEServer Objects

module-MiniAEFrame.html | module-MiniAEFrame.html | toolbox.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
3.5 MiniAEFrame (module-MiniAEFrame.html)
Up:
3.5 MiniAEFrame (module-MiniAEFrame.html)
Next:
4. MacOS Toolbox Modules (toolbox.html)
---
## 3.5.1 AEServer Objects
Note that there are some serious problems with the current
design. AppleEvents which have non-identifier 4-character designators
for arguments are not implementable, and it is not possible to return
an error to the originator. This will be addressed in a future
release.


2.3.2 Alias Objects

fsspec-objects.html | module-macfs.html | finfo-objects.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
2.3.1 FSSpec Objects (fsspec-objects.html)
Up:
2.3 macfs (module-macfs.html)
Next:
2.3.3 FInfo Objects (finfo-objects.html)
---
## 2.3.2 Alias Objects
Note that it is currently not possible to directly manipulate a
resource as an Alias object. Hence, after calling
Update() or after Resolve() indicates that the alias
has changed the Python program is responsible for getting the
data value from the Alias object and modifying the
resource.


2.9.1 Application Objects

module-FrameWork.html | module-FrameWork.html | window-objects.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
2.9 FrameWork (module-FrameWork.html)
Up:
2.9 FrameWork (module-FrameWork.html)
Next:
2.9.2 Window Objects (window-objects.html)
---
## 2.9.1 Application Objects
Application objects have the following methods, among others:


1.2.3 Simulating command line arguments

creator-code.html | getting.html | node14.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
1.2.2.2 Set Creator and (creator-code.html)
Up:
1.2 Getting and Installing (getting.html)
Next:
1.2.4 Creating a Python (node14.html)
---
## 1.2.3 Simulating command line arguments
There are two ways to simulate command-line arguments with MacPython-OS9.
1. via Interpreter options
- Hold the option-key down when launching your script. This will
bring up a dialog box of Python Interpreter options.
- Click ``Set Unix-style command line..'' button.
- Type the arguments into the ``Argument'' field.
- Click ``OK''
- Click ``Run''.
2. via drag and drop
If you save the script as an applet (see Section 1.3.4 (IDEapplet.html#IDEapplet)), you
can also simulate some command-line arguments via
``Drag-and-Drop''. In this case, the names of the files that were
dropped onto the applet will be appended to `sys.argv`, so that
it will appear to the script as though they had been typed on a
command line. As on Unix systems, the first item in `sys.srgv` is
the path to the applet, and the rest are the files dropped on the
applet.


1.2.5 Configuration

scripting-with-BBedit.html | getting.html | EditPythonPrefs.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
1.2.4.3 BBedit (scripting-with-BBedit.html)
Up:
1.2 Getting and Installing (getting.html)
Next:
1.2.5.1 EditPythonPrefs (EditPythonPrefs.html)
---
## 1.2.5 Configuration
The MacPython distribution comes with EditPythonPrefs, an
applet which will help you to customize the MacPython environment for
your working habits.


Contents

front.html | mac.html | using.html | Macintosh Library Modules | modindex.html | genindex.html
Previous:
Front Matter (front.html)
Up:
Macintosh Library Modules (mac.html)
Next:
1. Using Python on (using.html)
---
## Contents
Table of Contents
- Front Matter (front.html)
  1. Using Python on a Mac OS 9 Macintosh (using.html)
  - 1.1 Getting and Installing MacPython-OSX (getting-OSX.html)
  - 1.1.1 How to run a Python script (node5.html)
  1.1.2 Running scripts with a GUI (osx-gui-scripts.html)
  1.1.3 configuration (node7.html)
  1.2 Getting and Installing MacPython-OS9 (getting.html)
  - 1.2.1 Entering the interactive Interpreter (interpreter.html)
  1.2.2 How to run a Python script (node10.html)
  1.2.3 Simulating command line arguments (argv.html)
  1.2.4 Creating a Python script (node14.html)
  1.2.5 Configuration (configuration.html)
  1.3 The IDE (IDE.html)
  - 1.3.1 Using the ``Python Interactive'' window (node23.html)
  1.3.2 Writing a Python Script (IDEwrite.html)
  1.3.3 Executing a script from within the IDE (IDEexecution.html)
  1.3.4 ``Save as'' versus ``Save as Applet'' (IDEapplet.html)
  2. MacPython Modules (macpython-modules.html)
  - 2.1 mac -- Implementations for the os module (module-mac.html)
  2.2 macpath -- MacOS path manipulation functions (module-macpath.html)
  2.3 macfs -- Various file system services (module-macfs.html)
  - 2.3.1 FSSpec Objects (fsspec-objects.html)
  2.3.2 Alias Objects (alias-objects.html)
  2.3.3 FInfo Objects (finfo-objects.html)
  2.4 ic -- Access to Internet Config (module-ic.html)
  - 2.4.1 IC Objects (node35.html)
  2.5 MacOS -- Access to Mac OS interpreter features (module-MacOS.html)
  2.6 macostools -- Convenience routines for file manipulation (module-macostools.html)
  2.7 findertools -- The finder's Apple Events interface (module-findertools.html)
  2.8 EasyDialogs -- Basic Macintosh dialogs (module-EasyDialogs.html)
  - 2.8.1 ProgressBar Objects (progressbar-objects.html)
  2.9 FrameWork -- Interactive application framework (module-FrameWork.html)
  - 2.9.1 Application Objects (application-objects.html)
  2.9.2 Window Objects (window-objects.html)
  2.9.3 ControlsWindow Object (controlswindow-object.html)
  2.9.4 ScrolledWindow Object (scrolledwindow-object.html)
  2.9.5 DialogWindow Objects (dialogwindow-objects.html)
  2.10 autoGIL -- Global Interpreter Lock handling in event loops (module-autoGIL.html)
  3. MacPython OSA Modules (scripting.html)
  - 3.1 gensuitemodule -- Generate OSA stub packages (module-gensuitemodule.html)
  3.2 aetools -- OSA client support (module-aetools.html)
  3.3 aepack -- Conversion between Python variables and AppleEvent data containers (module-aepack.html)
  3.4 aetypes -- AppleEvent objects (module-aetypes.html)
  3.5 MiniAEFrame -- Open Scripting Architecture server support (module-MiniAEFrame.html)
  - 3.5.1 AEServer Objects (aeserver-objects.html)
  4. MacOS Toolbox Modules (toolbox.html)
  - 4.1 Carbon.AE -- Apple Events (module-Carbon.AE.html)
  4.2 Carbon.AH -- Apple Help (module-Carbon.AH.html)
  4.3 Carbon.App -- Appearance Manager (module-Carbon.App.html)
  4.4 Carbon.CF -- Core Foundation (module-Carbon.CF.html)
  4.5 Carbon.CG -- Core Graphics (module-Carbon.CG.html)
  4.6 Carbon.CarbonEvt -- Carbon Event Manager (module-Carbon.CaronEvt.html)
  4.7 Carbon.Cm -- Component Manager (module-Carbon.Cm.html)
  4.8 Carbon.Ctl -- Control Manager (module-Carbon.Ctl.html)
  4.9 Carbon.Dlg -- Dialog Manager (module-Carbon.Dlg.html)
  4.10 Carbon.Evt -- Event Manager (module-Carbon.Evt.html)
  4.11 Carbon.Fm -- Font Manager (module-Carbon.Fm.html)
  4.12 Carbon.Folder -- Folder Manager (module-Carbon.Folder.html)
  4.13 Carbon.Help -- Help Manager (module-Carbon.Help.html)
  4.14 Carbon.List -- List Manager (module-Carbon.List.html)
  4.15 Carbon.Menu -- Menu Manager (module-Carbon.Menu.html)
  4.16 Carbon.Mlte -- MultiLingual Text Editor (module-Carbon.Mlte.html)
  4.17 Carbon.Qd -- QuickDraw (module-Carbon.Qd.html)
  4.18 Carbon.Qdoffs -- QuickDraw Offscreen (module-Carbon.Qdoffs.html)
  4.19 Carbon.Qt -- QuickTime (module-Carbon.Qt.html)
  4.20 Carbon.Res -- Resource Manager and Handles (module-Carbon.Res.html)
  4.21 Carbon.Scrap -- Scrap Manager (module-Carbon.Scrap.html)
  4.22 Carbon.Snd -- Sound Manager (module-Carbon.Snd.html)
  4.23 Carbon.TE -- TextEdit (module-Carbon.TE.html)
  4.24 Carbon.Win -- Window Manager (module-Carbon.Win.html)
  4.25 ColorPicker -- Color selection dialog (module-ColorPicker.html)
  5. Undocumented Modules (undocumented-modules.html)
  - 5.1 applesingle -- AppleSingle decoder (module-applesingle.html)
  5.2 buildtools -- Helper module for BuildApplet and Friends (module-buildtools.html)
  5.3 py_resource -- Resources from Python code (module-pyresource.html)
  5.4 cfmfile -- Code Fragment Resource module (module-cfmfile.html)
  5.5 icopen -- Internet Config replacement for open() (module-icopen.html)
  5.6 macerrors -- Mac OS Errors (module-macerrors.html)
  5.7 macresource -- Locate script resources (module-macresource.html)
  5.8 Nav -- NavServices calls (module-Nac.html)
  5.9 mkcwproject -- Create CodeWarrior projects (module-mkcwproject.html)
  5.10 nsremote -- Wrapper around Netscape OSA modules (module-nsremote.html)
  5.11 PixMapWrapper -- Wrapper for PixMap objects (module-PixMapWrapper.html)
  5.12 preferences -- Application preferences manager (module-preferences.html)
  5.13 pythonprefs -- Preferences manager for Python (module-pythonprefs.html)
  5.14 quietconsole -- Non-visible standard output (module-quietconsole.html)
  5.15 videoreader -- Read QuickTime movies (module-videoreader.html)
  5.16 W -- Widgets built on FrameWork (module-W.html)
  5.17 waste -- non-Apple TextEdit replacement (module-waste.html)
  A. History and License (node99.html)
  - A.1 History of the software (node100.html)
  A.2 Terms and conditions for accessing or otherwise using Python (node101.html)
  Module Index (modindex.html)
  About this document ... (about.html)
End of Table of Contents


2.9.3 ControlsWindow Object

window-objects.html | module-FrameWork.html | scrolledwindow-object.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
2.9.2 Window Objects (window-objects.html)
Up:
2.9 FrameWork (module-FrameWork.html)
Next:
2.9.4 ScrolledWindow Object (scrolledwindow-object.html)
---
## 2.9.3 ControlsWindow Object
ControlsWindow objects have the following methods besides those of
`Window` objects:


1.2.2.2 Set Creator and Double Click

node11.html | node10.html | argv.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
1.2.2.1 Drag and drop (node11.html)
Up:
1.2.2 How to run (node10.html)
Next:
1.2.3 Simulating command line (argv.html)
---
### 1.2.2.2 Set Creator and Double Click
If the script that you want to launch has the appropriate Creator Code
and File Type you can simply double-click on the script to launch it.
To be ``double-clickable'' a file needs to be of type "TEXT",
with a creator code of "Pyth".
Setting the creator code and filetype can be done with the IDE (see
sections 1.3.2 (IDEwrite.html#IDEwrite) and 1.3.4 (IDEapplet.html#IDEapplet)), with an editor with a
Python mode (BBEdit) - see section
1.2.4 (scripting-with-BBedit.html#scripting-with-BBedit), or with assorted other Mac utilities, but
a script (fixfiletypes.py) has been included in the MacPython
distribution, making it possible to set the proper Type and Creator
Codes with Python.
The fixfiletypes.py script will change the file type and
creator codes for the indicated directory. To use
fixfiletypes.py:
1. Locate it in the scripts folder of the Mac folder of the
MacPython distribution.
2. Put all of the scripts that you want to fix in a folder with nothing
else in it.
3. Double-click on the fixfiletypes.py icon.
4. Navigate into the folder of files you want to fix, and press the
``Select current folder'' button.


1.2.5.3 Default startup options

search-path.html | configuration.html | IDE.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
1.2.5.2 Adding modules to (search-path.html)
Up:
1.2.5 Configuration (configuration.html)
Next:
1.3 The IDE (IDE.html)
---
### 1.2.5.3 Default startup options
The ``Default startup options...'' button in the
EditPythonPrefs dialog box gives you many options including
the ability to keep the ``Output'' window open after the script
terminates, and the ability to enter interactive mode after the
termination of the run script. The latter can be very helpful if you
want to examine the objects that were created during your script.


2.9.5 DialogWindow Objects

scrolledwindow-object.html | module-FrameWork.html | module-autoGIL.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
2.9.4 ScrolledWindow Object (scrolledwindow-object.html)
Up:
2.9 FrameWork (module-FrameWork.html)
Next:
2.10 autoGIL (module-autoGIL.html)
---
## 2.9.5 DialogWindow Objects
DialogWindow objects have the following methods besides those of
`Window` objects:


1.2.5.1 EditPythonPrefs

configuration.html | configuration.html | search-path.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
1.2.5 Configuration (configuration.html)
Up:
1.2.5 Configuration (configuration.html)
Next:
1.2.5.2 Adding modules to (search-path.html)
---
### 1.2.5.1 EditPythonPrefs
EditPythonPrefs gives you the capability to configure Python
to behave the way you want it to. There are two ways to use
EditPythonPrefs, you can use it to set the preferences in
general, or you can drop a particular Python engine onto it to
customize only that version. The latter can be handy if, for example,
you want to have a second copy of the PythonInterpreter that
keeps the output window open on a normal exit even though you prefer
to normally not work that way.
To change the default preferences, simply double-click on
EditPythonPrefs. To change the preferences only for one copy
of the Interpreter, drop the icon for that copy onto
EditPythonPrefs. You can also use EditPythonPrefs
in this fashion to set the preferences of the Python IDE and
any applets you create - see section 1.3.4 (IDEapplet.html#IDEapplet).


2.3.3 FInfo Objects

alias-objects.html | module-macfs.html | module-ic.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
2.3.2 Alias Objects (alias-objects.html)
Up:
2.3 macfs (module-macfs.html)
Next:
2.4 ic (module-ic.html)
---
## 2.3.3 FInfo Objects
See Inside Macintosh: Files for a complete description of what
the various fields mean.


Front Matter

mac.html | mac.html | contents.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
Macintosh Library Modules (mac.html)
Up:
Macintosh Library Modules (mac.html)
Next:
---
# Front Matter
Copyright © 2001, 2002, 2003 Python Software Foundation.
All rights reserved.
Copyright © 2000 BeOpen.com.
All rights reserved.
Copyright © 1995-2000 Corporation for National Research Initiatives.
All rights reserved.
Copyright © 1991-1995 Stichting Mathematisch Centrum.
All rights reserved.
See the end of this document for complete license and permissions
information.
### Abstract:
This library reference manual documents Python's extensions for the
Macintosh. It should be used in conjunction with the
Python Library Reference (../lib/lib.html), which documents
the standard library and built-in types.
This manual assumes basic knowledge about the Python language. For an
informal introduction to Python, see the
Python Tutorial (../tut/tut.html); the
Python Reference Manual (../ref/ref.html) remains the
highest authority on syntactic and semantic questions. Finally, the
manual entitled Extending and Embedding
the Python Interpreter (../ext/ext.html) describes how to add new extensions to Python
and how to embed it in other applications.


2.3.1 FSSpec Objects

module-macfs.html | module-macfs.html | alias-objects.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
2.3 macfs (module-macfs.html)
Up:
2.3 macfs (module-macfs.html)
Next:
2.3.2 Alias Objects (alias-objects.html)
---
## 2.3.1 FSSpec Objects


Index

modindex.html | mac.html | about.html | Macintosh Library Modules | contents.html | modindex.html
Previous:
Module Index (modindex.html)
Up:
Macintosh Library Modules (mac.html)
Next:
About this document ... (about.html)
---
## Index
---
_ (#letter-_) |
a (#letter-a) |
b (#letter-b) |
c (#letter-c) |
d (#letter-d) |
e (#letter-e) |
f (#letter-f) |
g (#letter-g) |
h (#letter-h) |
i (#letter-i) |
k (#letter-k) |
l (#letter-l) |
m (#letter-m) |
n (#letter-n) |
o (#letter-o) |
p (#letter-p) |
q (#letter-q) |
r (#letter-r) |
s (#letter-s) |
t (#letter-t) |
u (#letter-u) |
v (#letter-v) |
w (#letter-w)
---
## _ (underscore)
---
## A
---
## B
---
## C
---
## D
---
## E
---
## F
---
## G
---
## H
---
## I
---
## K
---
## L
---
## M
---
## N
---
## O
---
## P
---
## Q
---
## R
---
## S
---
## T
---
## U
---
## V
---
## W


using.html | using.html | node5.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
1. Using Python on (using.html)
Up:
1. Using Python on (using.html)
Next:
1.1.1 How to run (node5.html)
---
# 1.1 Getting and Installing MacPython-OSX
As of Python 2.3a2 the only sure way of getting MacPython-OSX on your machine
is getting a source distribution and building what is called a "framework Python".
The details are in the file Mac/OSX/README.
As binary installers become available the details will be posted to
http://www.cwi.nl/~jack/macpython.html.
What you get after installing is a number of things:
- A MacPython-2.3 folder in your Applications
folder. In here you find the PythonIDE Integrated Development Environment;
PythonLauncher, which handles double-clicking Python scripts from
the Finder; and the Package Manager.
- A fairly standard Unix commandline Python interpreter in
/usr/local/bin/python, but without the usual
/usr/local/lib/python.
- A framework /Library/Frameworks/Python.framework, where
all the action really is, but which you usually do not have to be aware of.
To uninstall MacPython you can simply remove these three things.
PythonIDE contains an Apple Help Viewer book called "MacPython Help"
which you can access through its help menu. If you are completely new to
Python you should start reading the IDE introduction in that document.
If you are familiar with Python on other Unix platforms you should
read the section on running Python scripts from the Unix shell.


node7.html | using.html | interpreter.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
1.1.3 configuration (node7.html)
Up:
1. Using Python on (using.html)
Next:
1.2.1 Entering the interactive (interpreter.html)
---
# 1.2 Getting and Installing MacPython-OS9
The most recent release version as well as possible newer experimental
versions are best found at the MacPython page maintained by Jack
Jansen: http://homepages.cwi.nl/~jack/macpython.html.
Please refer to the README included with your distribution for
the most up-to-date instructions.
Note that MacPython-OS9 runs fine on Mac OS X, and it runs in native
mode, not in the Classic environment. Unless you have specific
requirements for a CFM-based Python there is no reason not to
use MacPython-OSX, though.


1.3 The IDE

defaults.html | using.html | node23.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
1.2.5.3 Default startup options (defaults.html)
Up:
1. Using Python on (using.html)
Next:
1.3.1 Using the ``Python (node23.html)
---
# 1.3 The IDE
The Python IDE (Integrated Development Environment) is a
separate application that acts as a text editor for your Python code,
a class browser, a graphical debugger, and more.


IDEexecution.html | IDE.html | macpython-modules.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
1.3.3 Executing a script (IDEexecution.html)
Up:
1.3 The IDE (IDE.html)
Next:
2. MacPython Modules (macpython-modules.html)
---
## 1.3.4 ``Save as'' versus ``Save as Applet''
When you are done writing your Python script you have the option of
saving it as an ``applet'' (by selecting ``Save as applet'' from the
``File'' menu). This has a significant advantage in that you can drop
files or folders onto it, to pass them to the applet the way
command-line users would type them onto the command-line to pass them
as arguments to the script. However, you should make sure to save the
applet as a separate file, do not overwrite the script you are
writing, because you will not be able to edit it again.
Accessing the items passed to the applet via ``drag-and-drop'' is done
using the standard sys.argv mechanism. See the general
documentation for more
Note that saving a script as an applet will not make it runnable on a
system without a Python installation.


IDEwrite.html | IDE.html | IDEapplet.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
1.3.2 Writing a Python (IDEwrite.html)
Up:
1.3 The IDE (IDE.html)
Next:
1.3.4 ``Save as'' versus (IDEapplet.html)
---
## 1.3.3 Executing a script from within the IDE
You can run the script in the frontmost window of the Python
IDE by hitting the run all button. You should be aware, however that
if you use the Python convention "if __name__ == "__main__":" the
script will not be ``__main__'' by default. To get that
behaviour you must select the ``Run as __main__'' option from the
small black triangle on the top right of the document window. Note
that this option is associated with the file not the
application. It will stay active after a save, however; to shut
this feature off simply select it again.


1.3.2 Writing a Python Script

node23.html | IDE.html | IDEexecution.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
1.3.1 Using the ``Python (node23.html)
Up:
1.3 The IDE (IDE.html)
Next:
1.3.3 Executing a script (IDEexecution.html)
---
## 1.3.2 Writing a Python Script
In addition to using the Python IDE interactively, you can
also type out a complete Python program, saving it incrementally, and
execute it or smaller selections of it.
You can create a new script, open a previously saved script, and save
your currently open script by selecting the appropriate item in the
``File'' menu. Dropping a Python script onto the
Python IDE will open it for editting.
If you try to open a script with the Python IDE but either
can't locate it from the ``Open'' dialog box, or you get an error
message like ``Can't open file of type ...'' see section
1.2.2 (creator-code.html#creator-code).
When the Python IDE saves a script, it uses the creator code
settings which are available by clicking on the small black triangle
on the top right of the document window, and selecting ``save
options''. The default is to save the file with the Python
IDE as the creator, this means that you can open the file for editing
by simply double-clicking on its icon. You might want to change this
behaviour so that it will be opened by the
PythonInterpreter, and run. To do this simply choose
``Python Interpreter'' from the ``save options''. Note that these
options are associated with the file not the application.


Macintosh Library Modules

../index.html | front.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Up:
Python Documentation Index (../index.html)
Next:
Front Matter (front.html)
---
# Macintosh Library Modules
Guido van Rossum
Fred L. Drake, Jr., editor
PythonLabs
Email: python-docs@python.org
Release 2.3
July 29, 2003


getting.html | getting.html | node10.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
1.2 Getting and Installing (getting.html)
Up:
1.2 Getting and Installing (getting.html)
Next:
1.2.2 How to run (node10.html)
---
## 1.2.1 Entering the interactive Interpreter
The interactive interpreter that you will see used in Python
documentation is started by double-clicking the
PythonInterpreter icon, which looks like a 16-ton weight
falling. You should see the version information and the
">`>`> " prompt. Use it exactly as described in the
standard documentation.


Macintosh Library Modules


2. MacPython Modules

IDEapplet.html | mac.html | module-mac.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
1.3.4 ``Save as'' versus (IDEapplet.html)
Up:
Macintosh Library Modules (mac.html)
Next:
2.1 mac (module-mac.html)
---
# 2. MacPython Modules
The following modules are only available on the Macintosh, and are
documented here:
mac (module-mac.html) | Implementations for the os module.
macpath (module-macpath.html) | MacOS path manipulation functions.
macfs (module-macfs.html) | Support for FSSpec, the Alias Manager,
finder aliases, and the Standard File package.
ic (module-ic.html) | Access to Internet Config.
MacOS (module-MacOS.html) | Access to Mac OS-specific interpreter features.
macostools (module-macostools.html) | Convenience routines for file manipulation.
findertools (module-findertools.html) | Wrappers around the finder's Apple Events interface.
EasyDialogs (module-EasyDialogs.html) | Basic Macintosh dialogs.
FrameWork (module-FrameWork.html) | Interactive application framework.
autoGIL (module-autoGIL.html) | Global Interpreter Lock handling in event loops.


Module Index

node101.html | mac.html | genindex.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
A.2 Terms and conditions (node101.html)
Up:
Macintosh Library Modules (mac.html)
Next:
---
## Module Index
This index only lists modules documented in this manual.
The Global Module
Index (../modindex.html) lists all modules that are documented in this set
of manuals.
Some module names are followed by an annotation indicating what
platform they are available on.


module-aetools.html | scripting.html | module-aetypes.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
3.2 aetools (module-aetools.html)
Up:
3. MacPython OSA Modules (scripting.html)
Next:
3.4 aetypes (module-aetypes.html)
---
# 3.3 aepack --
Conversion between Python variables and AppleEvent data containers
Availability: Macintosh.
The aepack module defines functions for converting (packing)
Python variables to AppleEvent descriptors and back (unpacking).
Within Python the AppleEvent descriptor is handled by Python objects
of built-in type AEDesc, defined in module AE (module-AE.html).
The aepack module defines the following functions:


3.2 aetools -- OSA client support

module-gensuitemodule.html | scripting.html | module-aepack.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
3.1 gensuitemodule (module-gensuitemodule.html)
Up:
3. MacPython OSA Modules (scripting.html)
Next:
3.3 aepack (module-aepack.html)
---
# 3.2 aetools --
OSA client support
Availability: Macintosh.
The aetools module contains the basic functionality
on which Python AppleScript client support is built. It also
imports and re-exports the core functionality of the
aetypes and aepack modules. The stub packages
generated by gensuitemodule import the relevant
portions of aetools, so usually you do not need to
import it yourself. The exception to this is when you
cannot use a generated suite package and need lower-level
access to scripting.
The aetools module itself uses the AppleEvent support
provided by the Carbon.AE module. This has one drawback:
you need access to the window manager, see section 1.1.2 (osx-gui-scripts.html#osx-gui-scripts)
for details. This restriction may be lifted in future releases.
The aetools module defines the following functions:
The aetools module defines the following class:


3.4 aetypes -- AppleEvent objects

module-aepack.html | scripting.html | module-MiniAEFrame.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
3.3 aepack (module-aepack.html)
Up:
3. MacPython OSA Modules (scripting.html)
Next:
3.5 MiniAEFrame (module-MiniAEFrame.html)
---
# 3.4 aetypes --
AppleEvent objects
Availability: Macintosh.
The aetypes defines classes used to represent Apple Event data
descriptors and Apple Event object specifiers.
Apple Event data is is contained in descriptors, and these descriptors
are typed. For many descriptors the Python representation is simply the
corresponding Python type: `typeText` in OSA is a Python string,
`typeFloat` is a float, etc. For OSA types that have no direct
Python counterpart this module declares classes. Packing and unpacking
instances of these classes is handled automatically by aepack.
An object specifier is essentially an address of an object implemented
in a Apple Event server. An Apple Event specifier is used as the direct
object for an Apple Event or as the argument of an optional parameter.
The aetypes module contains the base classes for OSA classes
and properties, which are used by the packages generated by
gensuitemodule to populate the classes and properties in a
given suite.
For reasons of backward compatibility, and for cases where you need to
script an application for which you have not generated the stub package
this module also contains object specifiers for a number of common OSA
classes such as `Document`, `Window`, `Character`, etc.
The AEObjects module defines the following classes to represent
Apple Event descriptor data:
The following classes are used as base classes by the generated stub
packages to represent AppleScript classes and properties in Python:


5.1 applesingle -- AppleSingle decoder

undocumented-modules.html | undocumented-modules.html | module-buildtools.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
5. Undocumented Modules (undocumented-modules.html)
Up:
5. Undocumented Modules (undocumented-modules.html)
Next:
5.2 buildtools (module-buildtools.html)
---
# 5.1 applesingle -- AppleSingle decoder
Availability: Macintosh.


dialogwindow-objects.html | macpython-modules.html | scripting.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
2.9.5 DialogWindow Objects (dialogwindow-objects.html)
Up:
2. MacPython Modules (macpython-modules.html)
Next:
3. MacPython OSA Modules (scripting.html)
---
# 2.10 autoGIL --
Global Interpreter Lock handling in event loops
Availability: Macintosh.
The autoGIL module provides a function installAutoGIL that
automatically locks and unlocks Python's Global Interpreter Lock
when running an event loop.


module-applesingle.html | undocumented-modules.html | module-pyresource.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
5.1 applesingle (module-applesingle.html)
Up:
5. Undocumented Modules (undocumented-modules.html)
Next:
5.3 py_resource (module-pyresource.html)
---
# 5.2 buildtools -- Helper module for BuildApplet and Friends
Availability: Macintosh.


4.1 Carbon.AE -- Apple Events

toolbox.html | toolbox.html | module-Carbon.AH.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
4. MacOS Toolbox Modules (toolbox.html)
Up:
4. MacOS Toolbox Modules (toolbox.html)
Next:
4.2 Carbon.AH (module-Carbon.AH.html)
---
# 4.1 Carbon.AE -- Apple Events
Availability: Macintosh.


4.2 Carbon.AH -- Apple Help

module-Carbon.AE.html | toolbox.html | module-Carbon.App.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
4.1 Carbon.AE (module-Carbon.AE.html)
Up:
4. MacOS Toolbox Modules (toolbox.html)
Next:
4.3 Carbon.App (module-Carbon.App.html)
---
# 4.2 Carbon.AH -- Apple Help
Availability: Macintosh.


4.3 Carbon.App -- Appearance Manager

module-Carbon.AH.html | toolbox.html | module-Carbon.CF.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
4.2 Carbon.AH (module-Carbon.AH.html)
Up:
4. MacOS Toolbox Modules (toolbox.html)
Next:
4.4 Carbon.CF (module-Carbon.CF.html)
---
# 4.3 Carbon.App -- Appearance Manager
Availability: Macintosh.


module-Carbon.CG.html | toolbox.html | module-Carbon.Cm.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
4.5 Carbon.CG (module-Carbon.CG.html)
Up:
4. MacOS Toolbox Modules (toolbox.html)
Next:
4.7 Carbon.Cm (module-Carbon.Cm.html)
---
# 4.6 Carbon.CarbonEvt -- Carbon Event Manager
Availability: Macintosh.


4.4 Carbon.CF -- Core Foundation

module-Carbon.App.html | toolbox.html | module-Carbon.CG.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
4.3 Carbon.App (module-Carbon.App.html)
Up:
4. MacOS Toolbox Modules (toolbox.html)
Next:
4.5 Carbon.CG (module-Carbon.CG.html)
---
# 4.4 Carbon.CF -- Core Foundation
Availability: Macintosh.
The
`CFBase`, `CFArray`, `CFData`, `CFDictionary`,
`CFString` and `CFURL` objects are supported, some
only partially.


4.5 Carbon.CG -- Core Graphics

module-Carbon.CF.html | toolbox.html | module-Carbon.CaronEvt.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
4.4 Carbon.CF (module-Carbon.CF.html)
Up:
4. MacOS Toolbox Modules (toolbox.html)
Next:
4.6 Carbon.CarbonEvt (module-Carbon.CaronEvt.html)
---
# 4.5 Carbon.CG -- Core Graphics
Availability: Macintosh.


4.7 Carbon.Cm -- Component Manager

module-Carbon.CaronEvt.html | toolbox.html | module-Carbon.Ctl.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
4.6 Carbon.CarbonEvt (module-Carbon.CaronEvt.html)
Up:
4. MacOS Toolbox Modules (toolbox.html)
Next:
4.8 Carbon.Ctl (module-Carbon.Ctl.html)
---
# 4.7 Carbon.Cm -- Component Manager
Availability: Macintosh.


4.8 Carbon.Ctl -- Control Manager

module-Carbon.Cm.html | toolbox.html | module-Carbon.Dlg.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
4.7 Carbon.Cm (module-Carbon.Cm.html)
Up:
4. MacOS Toolbox Modules (toolbox.html)
Next:
4.9 Carbon.Dlg (module-Carbon.Dlg.html)
---
# 4.8 Carbon.Ctl -- Control Manager
Availability: Macintosh.


4.9 Carbon.Dlg -- Dialog Manager

module-Carbon.Ctl.html | toolbox.html | module-Carbon.Evt.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
4.8 Carbon.Ctl (module-Carbon.Ctl.html)
Up:
4. MacOS Toolbox Modules (toolbox.html)
Next:
4.10 Carbon.Evt (module-Carbon.Evt.html)
---
# 4.9 Carbon.Dlg -- Dialog Manager
Availability: Macintosh.


4.10 Carbon.Evt -- Event Manager

module-Carbon.Dlg.html | toolbox.html | module-Carbon.Fm.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
4.9 Carbon.Dlg (module-Carbon.Dlg.html)
Up:
4. MacOS Toolbox Modules (toolbox.html)
Next:
4.11 Carbon.Fm (module-Carbon.Fm.html)
---
# 4.10 Carbon.Evt -- Event Manager
Availability: Macintosh.


4.11 Carbon.Fm -- Font Manager

module-Carbon.Evt.html | toolbox.html | module-Carbon.Folder.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
4.10 Carbon.Evt (module-Carbon.Evt.html)
Up:
4. MacOS Toolbox Modules (toolbox.html)
Next:
4.12 Carbon.Folder (module-Carbon.Folder.html)
---
# 4.11 Carbon.Fm -- Font Manager
Availability: Macintosh.


4.12 Carbon.Folder -- Folder Manager

module-Carbon.Fm.html | toolbox.html | module-Carbon.Help.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
4.11 Carbon.Fm (module-Carbon.Fm.html)
Up:
4. MacOS Toolbox Modules (toolbox.html)
Next:
4.13 Carbon.Help (module-Carbon.Help.html)
---
# 4.12 Carbon.Folder -- Folder Manager
Availability: Macintosh.


4.13 Carbon.Help -- Help Manager

module-Carbon.Folder.html | toolbox.html | module-Carbon.List.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
4.12 Carbon.Folder (module-Carbon.Folder.html)
Up:
4. MacOS Toolbox Modules (toolbox.html)
Next:
4.14 Carbon.List (module-Carbon.List.html)
---
# 4.13 Carbon.Help -- Help Manager
Availability: Macintosh.


4.14 Carbon.List -- List Manager

module-Carbon.Help.html | toolbox.html | module-Carbon.Menu.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
4.13 Carbon.Help (module-Carbon.Help.html)
Up:
4. MacOS Toolbox Modules (toolbox.html)
Next:
4.15 Carbon.Menu (module-Carbon.Menu.html)
---
# 4.14 Carbon.List -- List Manager
Availability: Macintosh.


4.15 Carbon.Menu -- Menu Manager

module-Carbon.List.html | toolbox.html | module-Carbon.Mlte.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
4.14 Carbon.List (module-Carbon.List.html)
Up:
4. MacOS Toolbox Modules (toolbox.html)
Next:
4.16 Carbon.Mlte (module-Carbon.Mlte.html)
---
# 4.15 Carbon.Menu -- Menu Manager
Availability: Macintosh.


module-Carbon.Menu.html | toolbox.html | module-Carbon.Qd.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
4.15 Carbon.Menu (module-Carbon.Menu.html)
Up:
4. MacOS Toolbox Modules (toolbox.html)
Next:
4.17 Carbon.Qd (module-Carbon.Qd.html)
---
# 4.16 Carbon.Mlte -- MultiLingual Text Editor
Availability: Macintosh.


4.17 Carbon.Qd -- QuickDraw

module-Carbon.Mlte.html | toolbox.html | module-Carbon.Qdoffs.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
4.16 Carbon.Mlte (module-Carbon.Mlte.html)
Up:
4. MacOS Toolbox Modules (toolbox.html)
Next:
4.18 Carbon.Qdoffs (module-Carbon.Qdoffs.html)
---
# 4.17 Carbon.Qd -- QuickDraw
Availability: Macintosh.


module-Carbon.Qd.html | toolbox.html | module-Carbon.Qt.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
4.17 Carbon.Qd (module-Carbon.Qd.html)
Up:
4. MacOS Toolbox Modules (toolbox.html)
Next:
4.19 Carbon.Qt (module-Carbon.Qt.html)
---
# 4.18 Carbon.Qdoffs -- QuickDraw Offscreen
Availability: Macintosh.


4.19 Carbon.Qt -- QuickTime

module-Carbon.Qdoffs.html | toolbox.html | module-Carbon.Res.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
4.18 Carbon.Qdoffs (module-Carbon.Qdoffs.html)
Up:
4. MacOS Toolbox Modules (toolbox.html)
Next:
4.20 Carbon.Res (module-Carbon.Res.html)
---
# 4.19 Carbon.Qt -- QuickTime
Availability: Macintosh.


module-Carbon.Qt.html | toolbox.html | module-Carbon.Scrap.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
4.19 Carbon.Qt (module-Carbon.Qt.html)
Up:
4. MacOS Toolbox Modules (toolbox.html)
Next:
4.21 Carbon.Scrap (module-Carbon.Scrap.html)
---
# 4.20 Carbon.Res -- Resource Manager and Handles
Availability: Macintosh.


4.21 Carbon.Scrap -- Scrap Manager

module-Carbon.Res.html | toolbox.html | module-Carbon.Snd.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
4.20 Carbon.Res (module-Carbon.Res.html)
Up:
4. MacOS Toolbox Modules (toolbox.html)
Next:
4.22 Carbon.Snd (module-Carbon.Snd.html)
---
# 4.21 Carbon.Scrap -- Scrap Manager
Availability: Macintosh.


4.22 Carbon.Snd -- Sound Manager

module-Carbon.Scrap.html | toolbox.html | module-Carbon.TE.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
4.21 Carbon.Scrap (module-Carbon.Scrap.html)
Up:
4. MacOS Toolbox Modules (toolbox.html)
Next:
4.23 Carbon.TE (module-Carbon.TE.html)
---
# 4.22 Carbon.Snd -- Sound Manager
Availability: Macintosh.


4.23 Carbon.TE -- TextEdit

module-Carbon.Snd.html | toolbox.html | module-Carbon.Win.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
4.22 Carbon.Snd (module-Carbon.Snd.html)
Up:
4. MacOS Toolbox Modules (toolbox.html)
Next:
4.24 Carbon.Win (module-Carbon.Win.html)
---
# 4.23 Carbon.TE -- TextEdit
Availability: Macintosh.


4.24 Carbon.Win -- Window Manager

module-Carbon.TE.html | toolbox.html | module-ColorPicker.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
4.23 Carbon.TE (module-Carbon.TE.html)
Up:
4. MacOS Toolbox Modules (toolbox.html)
Next:
4.25 ColorPicker (module-ColorPicker.html)
---
# 4.24 Carbon.Win -- Window Manager
Availability: Macintosh.


module-pyresource.html | undocumented-modules.html | module-icopen.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
5.3 py_resource (module-pyresource.html)
Up:
5. Undocumented Modules (undocumented-modules.html)
Next:
5.5 icopen (module-icopen.html)
---
# 5.4 cfmfile -- Code Fragment Resource module
Availability: Macintosh.
cfmfile is a module that understands Code Fragments and the
accompanying ``cfrg'' resources. It can parse them and merge them, and is
used by BuildApplication to combine all plugin modules to a single
executable.


module-Carbon.Win.html | toolbox.html | undocumented-modules.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
4.24 Carbon.Win (module-Carbon.Win.html)
Up:
4. MacOS Toolbox Modules (toolbox.html)
Next:
5. Undocumented Modules (undocumented-modules.html)
---
# 4.25 ColorPicker --
Color selection dialog
Availability: Macintosh.
The ColorPicker module provides access to the standard color
picker dialog.


module-findertools.html | macpython-modules.html | progressbar-objects.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
2.7 findertools (module-findertools.html)
Up:
2. MacPython Modules (macpython-modules.html)
Next:
2.8.1 ProgressBar Objects (progressbar-objects.html)
---
# 2.8 EasyDialogs --
Basic Macintosh dialogs
Availability: Macintosh.
The EasyDialogs module contains some simple dialogs for the
Macintosh. All routines take an optional resource ID parameter id
with which one can override the DLOG resource used for the
dialog, provided that the dialog items correspond (both type and item
number) to those in the default DLOG resource. See source
code for details.
The EasyDialogs module defines the following functions:


module-macostools.html | macpython-modules.html | module-EasyDialogs.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
2.6 macostools (module-macostools.html)
Up:
2. MacPython Modules (macpython-modules.html)
Next:
2.8 EasyDialogs (module-EasyDialogs.html)
---
# 2.7 findertools --
The finder's Apple Events interface
Availability: Macintosh.
This module contains routines that give Python programs access to some
functionality provided by the finder. They are implemented as wrappers
around the AppleEventinterface to the finder.
All file and folder parameters can be specified either as full
pathnames, or as FSRef or FSSpec objects.
The findertools module defines the following functions:


progressbar-objects.html | macpython-modules.html | application-objects.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
2.8.1 ProgressBar Objects (progressbar-objects.html)
Up:
2. MacPython Modules (macpython-modules.html)
Next:
2.9.1 Application Objects (application-objects.html)
---
# 2.9 FrameWork --
Interactive application framework
Availability: Macintosh.
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, i.e. to handle clicks in a single dialog window in a
non-standard way it is not necessary to override the complete event
handling.
The FrameWork is still very much work-in-progress, and the
documentation describes only the most important functionality, and not
in the most logical manner at that. Examine the source or the examples
for more details. The following are some comments posted on the
MacPython newsgroup about the strengths and limitations of
FrameWork:
> The strong point of FrameWork is that it allows you to break
> into the control-flow at many different places. W (module-W.html), for
> instance, uses a different way to enable/disable menus and that plugs
> right in leaving the rest intact. The weak points of
> FrameWork are that it has no abstract command interface (but
> that shouldn't be difficult), that it's dialog support is minimal and
> that it's control/toolbar support is non-existent.
The FrameWork module defines the following functions:


scripting.html | scripting.html | module-aetools.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
3. MacPython OSA Modules (scripting.html)
Up:
3. MacPython OSA Modules (scripting.html)
Next:
3.2 aetools (module-aetools.html)
---
# 3.1 gensuitemodule --
Generate OSA stub packages
Availability: Macintosh.
The gensuitemodule module creates a Python package implementing
stub code for the AppleScript suites that are implemented by a specific
application, according to its AppleScript dictionary.
It is usually invoked by the user through the PythonIDE, but
it can also be run as a script from the command line (pass `-help`
for help on the options) or imported from Python code. For an example of
its use see Mac/scripts/genallsuites.py in a source distribution,
which generates the stub packages that are included in the standard
library.
It defines the following public functions:


2.4 ic -- Access to Internet Config

finfo-objects.html | macpython-modules.html | node35.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
2.3.3 FInfo Objects (finfo-objects.html)
Up:
2. MacPython Modules (macpython-modules.html)
Next:
2.4.1 IC Objects (node35.html)
---
# 2.4 ic --
Access to Internet Config
Availability: Macintosh.
This module provides access to Macintosh Internet
Configpackage,
which stores preferences for Internet programs such as mail address,
default homepage, etc. 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,
etc.). Since MacOS 9, this module is a control panel named Internet.
There is a low-level companion module
icgluewhich provides the basic
Internet Config access functionality. This low-level module is not
documented, but the docstrings of the routines document the parameters
and the routine names are the same as for the Pascal or C API to
Internet Config, so the standard IC programmers' documentation can be
used if this module is needed.
The ic module defines the error exception and
symbolic names for all error codes Internet Config can produce; see
the source for details.
The ic module defines the following class and function:


module-cfmfile.html | undocumented-modules.html | module-macerrors.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
5.4 cfmfile (module-cfmfile.html)
Up:
5. Undocumented Modules (undocumented-modules.html)
Next:
5.6 macerrors (module-macerrors.html)
---
# 5.5 icopen -- Internet Config replacement for open()
Availability: Macintosh.
Importing icopen will replace the builtin open()
with a version that uses Internet Config to set file type and creator
for new files.


macpython-modules.html | macpython-modules.html | module-macpath.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
2. MacPython Modules (macpython-modules.html)
Up:
2. MacPython Modules (macpython-modules.html)
Next:
2.2 macpath (module-macpath.html)
---
# 2.1 mac --
Implementations for the os module
Availability: Macintosh.
This module implements the Mac OS 9 operating system dependent functionality
provided by the standard module os. It is
best accessed through the os module. This module is only available in
MacPython-OS9, on MacPython-OSX posix is used.
The following functions are available in this module:
chdir(),
close(),
dup(),
fdopen(),
getcwd(),
lseek(),
listdir(),
mkdir(),
open(),
read(),
rename(),
rmdir(),
stat(),
sync(),
unlink(),
write(),
as well as the exception error. Note that the times
returned by stat() are floating-point values, like all time
values in MacPython-OS9.


5.6 macerrors -- Mac OS Errors

module-icopen.html | undocumented-modules.html | module-macresource.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
5.5 icopen (module-icopen.html)
Up:
5. Undocumented Modules (undocumented-modules.html)
Next:
5.7 macresource (module-macresource.html)
---
# 5.6 macerrors -- Mac OS Errors
Availability: Macintosh.
macerrors cotains constant definitions for many Mac OS error
codes.


module-macpath.html | macpython-modules.html | fsspec-objects.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
2.2 macpath (module-macpath.html)
Up:
2. MacPython Modules (macpython-modules.html)
Next:
2.3.1 FSSpec Objects (fsspec-objects.html)
---
# 2.3 macfs --
Various file system services
Availability: Macintosh.
Deprecated since release 2.3.
The macfs module should be considered obsolete. For
FSSpec, FSRef and Alias handling use the
Carbon.File or Carbon.Folder module. For file dialogs use the
EasyDialogs module.
This module provides access to Macintosh FSSpec handling, the Alias
Manager, finder aliases and the Standard File package.
Whenever a function or method expects a file argument, this
argument can be one of three things: (1) a full or partial Macintosh
pathname, (2) an FSSpec object or (3) a 3-tuple
`( wdRefNum , parID , name )` as described in
Inside Macintosh: Files. An FSSpec can point to
a non-existing file, as long as the folder containing the file exists.
Under MacPython the same is true for a pathname, but not under unix-Pyton
because of the way pathnames and FSRefs works. See Apple's documentation
for details.
A description of aliases and the
Standard File package can also be found there.


node35.html | macpython-modules.html | module-macostools.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
2.4.1 IC Objects (node35.html)
Up:
2. MacPython Modules (macpython-modules.html)
Next:
2.6 macostools (module-macostools.html)
---
# 2.5 MacOS --
Access to Mac OS interpreter features
Availability: Macintosh.
This module provides access to MacOS specific functionality in the
Python interpreter, such as how the interpreter eventloop functions
and the like. Use with care.
Note the capitalization of the module name; this is a historical
artifact.


module-MacOS.html | macpython-modules.html | module-findertools.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
2.5 MacOS (module-MacOS.html)
Up:
2. MacPython Modules (macpython-modules.html)
Next:
2.7 findertools (module-findertools.html)
---
# 2.6 macostools --
Convenience routines for file manipulation
Availability: Macintosh.
This module contains some convenience routines for file-manipulation
on the Macintosh. All file parameters can be specified as
pathnames, FSRef or FSSpec objects.
The macostools module defines the following functions:
Note that the process of creating finder aliases is not specified in
the Apple documentation. Hence, aliases created with mkalias()
could conceivably have incompatible behaviour in some cases.


module-mac.html | macpython-modules.html | module-macfs.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
2.1 mac (module-mac.html)
Up:
2. MacPython Modules (macpython-modules.html)
Next:
2.3 macfs (module-macfs.html)
---
# 2.2 macpath --
MacOS path manipulation functions
This module is the Macintosh implementation of the os.path
module. It is most portably accessed as
os.path. Refer to the
Python Library Reference (../lib/lib.html) for
documentation of os.path.


module-macerrors.html | undocumented-modules.html | module-Nac.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
5.6 macerrors (module-macerrors.html)
Up:
5. Undocumented Modules (undocumented-modules.html)
Next:
5.8 Nav (module-Nac.html)
---
# 5.7 macresource -- Locate script resources
Availability: Macintosh.
macresource helps scripts finding their resources, such as
dialogs and menus, without requiring special case code for when the
script is run under MacPython, as a MacPython applet or under OSX Python.


module-aetypes.html | scripting.html | aeserver-objects.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
3.4 aetypes (module-aetypes.html)
Up:
3. MacPython OSA Modules (scripting.html)
Next:
3.5.1 AEServer Objects (aeserver-objects.html)
---
# 3.5 MiniAEFrame --
Open Scripting Architecture server support
Availability: Macintosh.
The module MiniAEFrame provides a framework for an application
that can function as an Open Scripting Architecture
(OSA) server, i.e. receive and process
AppleEvents. It can be used in conjunction with
FrameWork (module-FrameWork.html)or standalone. As an
example, it is used in PythonCGISlave.
The MiniAEFrame module defines the following classes:


module-Nac.html | undocumented-modules.html | module-nsremote.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
5.8 Nav (module-Nac.html)
Up:
5. Undocumented Modules (undocumented-modules.html)
Next:
5.10 nsremote (module-nsremote.html)
---
# 5.9 mkcwproject -- Create CodeWarrior projects
Availability: Macintosh.
mkcwproject creates project files for the Metrowerks CodeWarrior
development environment. It is a helper module for
distutils (module-distutils.html)but can be used separately for more
control.


5.8 Nav -- NavServices calls

module-macresource.html | undocumented-modules.html | module-mkcwproject.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
5.7 macresource (module-macresource.html)
Up:
5. Undocumented Modules (undocumented-modules.html)
Next:
5.9 mkcwproject (module-mkcwproject.html)
---
# 5.8 Nav -- NavServices calls
Availability: Macintosh.
A low-level interface to Navigation Services.


module-mkcwproject.html | undocumented-modules.html | module-PixMapWrapper.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
5.9 mkcwproject (module-mkcwproject.html)
Up:
5. Undocumented Modules (undocumented-modules.html)
Next:
5.11 PixMapWrapper (module-PixMapWrapper.html)
---
# 5.10 nsremote -- Wrapper around Netscape OSA modules
Availability: Macintosh.
nsremote is a wrapper around the Netscape OSA modules that
allows you to easily send your browser to a given URL. A related
module that may be of interest is the webbrowser module,
documented in the Python Library
Reference (../lib/lib.html).


module-nsremote.html | undocumented-modules.html | module-preferences.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
5.10 nsremote (module-nsremote.html)
Up:
5. Undocumented Modules (undocumented-modules.html)
Next:
5.12 preferences (module-preferences.html)
---
# 5.11 PixMapWrapper -- Wrapper for PixMap objects
Availability: Macintosh.
PixMapWrapper wraps a PixMap object with a Python object that
allows access to the fields by name. It also has methods to convert
to and from PIL images.


module-PixMapWrapper.html | undocumented-modules.html | module-pythonprefs.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
5.11 PixMapWrapper (module-PixMapWrapper.html)
Up:
5. Undocumented Modules (undocumented-modules.html)
Next:
5.13 pythonprefs (module-pythonprefs.html)
---
# 5.12 preferences -- Application preferences manager
Availability: Macintosh.
The preferences module allows storage of user preferences in
the system-wide preferences folder, with defaults coming from the
application itself and the possibility to override preferences for
specific situations.


module-buildtools.html | undocumented-modules.html | module-cfmfile.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
5.2 buildtools (module-buildtools.html)
Up:
5. Undocumented Modules (undocumented-modules.html)
Next:
5.4 cfmfile (module-cfmfile.html)
---
# 5.3 py_resource -- Resources from Python code
Availability: Macintosh.
This module is primarily used as a help module for
BuildApplet and BuildApplication. It is able to
store compiled Python code as 'PYC ' resources in a file.


module-preferences.html | undocumented-modules.html | module-quietconsole.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
5.12 preferences (module-preferences.html)
Up:
5. Undocumented Modules (undocumented-modules.html)
Next:
5.14 quietconsole (module-quietconsole.html)
---
# 5.13 pythonprefs -- Preferences manager for Python
Availability: Macintosh.
This module is a specialization of the preferences (module-preferences.html) module
that allows reading and writing of the preferences for the Python
interpreter.


module-pythonprefs.html | undocumented-modules.html | module-videoreader.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
5.13 pythonprefs (module-pythonprefs.html)
Up:
5. Undocumented Modules (undocumented-modules.html)
Next:
5.15 videoreader (module-videoreader.html)
---
# 5.14 quietconsole -- Non-visible standard output
Availability: Macintosh.
quietconsole allows you to keep stdio output in a buffer
without displaying it (or without displaying the stdout window
altogether, if set with EditPythonPrefs) until you try to read from
stdin or disable the buffering, at which point all the saved output is
sent to the window. Good for programs with graphical user interfaces
that do want to display their output at a crash.


module-quietconsole.html | undocumented-modules.html | module-W.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
5.14 quietconsole (module-quietconsole.html)
Up:
5. Undocumented Modules (undocumented-modules.html)
Next:
5.16 W (module-W.html)
---
# 5.15 videoreader -- Read QuickTime movies
Availability: Macintosh.
videoreader reads and decodes QuickTime movies and passes
a stream of images to your program. It also provides some support for
audio tracks.


5.16 W -- Widgets built on FrameWork

module-videoreader.html | undocumented-modules.html | module-waste.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
5.15 videoreader (module-videoreader.html)
Up:
5. Undocumented Modules (undocumented-modules.html)
Next:
5.17 waste (module-waste.html)
---
# 5.16 W -- Widgets built on FrameWork
Availability: Macintosh.
The W widgets are used extensively in the IDE.


module-W.html | undocumented-modules.html | node99.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
5.16 W (module-W.html)
Up:
5. Undocumented Modules (undocumented-modules.html)
Next:
A. History and License (node99.html)
---
# 5.17 waste -- non-Apple TextEdit replacement
Availability: Macintosh.
See Also:


1.2.2 How to run a Python script

interpreter.html | getting.html | node11.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
1.2.1 Entering the interactive (interpreter.html)
Up:
1.2 Getting and Installing (getting.html)
Next:
1.2.2.1 Drag and drop (node11.html)
---
## 1.2.2 How to run a Python script
There are several ways to run an existing Python script; two common
ways to run a Python script are ``drag and drop'' and ``double
clicking''. Other ways include running it from within the IDE (see
Section 1.3 (IDE.html#IDE)), or launching via AppleScript.


A.1 History of the software

node99.html | node99.html | node101.html | Macintosh Library Modules | contents.html | modindex.html | genindex.html
Previous:
A. History and License (node99.html)
Up:
A. History and License (node99.html)
Next:
A.2 Terms and conditions (node101.html)
---
# A.1 History of the software
Python was created in the early 1990s by Guido van Rossum at Stichting
Mathematisch Centrum (CWI, see http://www.cwi.nl/) in the Netherlands
as a successor of a language called ABC. Guido remains Python's
principal author, although it includes many contributions from others.
In 1995, Guido continued his work on Python at the Corporation for
National Research Initiatives (CNRI, see http://www.cnri.reston.va.us/)
in Reston, Virginia where he released several versions of the
software.
In May 2000, Guido and the Python core development team moved to
BeOpen.com to form the BeOpen PythonLabs team. In October of the same
year, the PythonLabs team moved to Digital Creations (now Zope
Corporation; see http://www.zope.com/). In 2001, the Python
Software Foundation (PSF, see http://www.python.org/psf/) was
formed, a non-profit organization created specifically to own
Python-related Intellectual Property. Zope Corporation is a
sponsoring member of the PSF.
All Python releases are Open Source (see
http://www.opensource.org/ for the Open Source Definition).
Historically, most, but not all, Python releases have also been
GPL-compatible; the table below summarizes the various releases.
Note:
GPL-compatible doesn't mean that we're distributing
Python under the GPL. All Python licenses, unlike the GPL, let you
distribute a modified version without making your changes open source.
The GPL-compatible licenses make it possible to combine Python with
other software that is released under the GPL; the others don't.
Thanks to the many outside volunteers who have worked under Guido's
direction to make these releases possible.