]> granicus.if.org Git - python/commit
Rewrote the basic section of the chapter on defining new types.
authorJim Fulton <jim@zope.com>
Wed, 7 May 2003 19:48:13 +0000 (19:48 +0000)
committerJim Fulton <jim@zope.com>
Wed, 7 May 2003 19:48:13 +0000 (19:48 +0000)
commitaed0a4a138c488b4731369f93fe434612647cfe7
treeedda5a6c4aecd48e77ea214a94b395b30c6de04a
parenta02469f9692cc5c1503dd35728c61789f4e8242f
Rewrote the basic section of the chapter on defining new types.
Changed the example to show how to create types the new way:

- Use a class new method rather than a new function.

- Use self->ob_type->tp_free in deallocators

- Use attribute descriptors rather than set/getattr methods.

- Make the type usable as a base type.

I split the example into 3 parts:

1. The minimal new type

2. Adding attributes and methods.

3. Finer control over attributes.

It's much simpler to define builtin types. These updates hopefully
show this.

I also made minor wording changes in two other places.

I still need to update xxobject.c
Doc/ext/newtypes.tex
Doc/ext/noddy2.c [new file with mode: 0644]
Doc/ext/noddy3.c [new file with mode: 0644]