Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
2 | <html> | |
3 | <head> | |
4 | <link rel="STYLESHEET" href="ext.css" type='text/css' /> | |
5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> | |
6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> | |
7 | <link rel="first" href="ext.html" title='Extending and Embedding the Python Interpreter' /> | |
8 | <link rel='contents' href='contents.html' title="Contents" /> | |
9 | <link rel='last' href='about.html' title='About this document...' /> | |
10 | <link rel='help' href='about.html' title='About this document...' /> | |
11 | <link rel="next" href="building.html" /> | |
12 | <link rel="prev" href="intro.html" /> | |
13 | <link rel="parent" href="ext.html" /> | |
14 | <link rel="next" href="dnt-basics.html" /> | |
15 | <meta name='aesop' content='information' /> | |
16 | <title>2. Defining New Types | |
17 | </title> | |
18 | </head> | |
19 | <body> | |
20 | <DIV CLASS="navigation"> | |
21 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> | |
22 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
23 | <tr> | |
24 | <td class='online-navigation'><a rel="prev" title="1.12 Providing a C" | |
25 | href="using-cobjects.html"><img src='../icons/previous.png' | |
26 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
27 | <td class='online-navigation'><a rel="parent" title="Extending and Embedding the" | |
28 | href="ext.html"><img src='../icons/up.png' | |
29 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
30 | <td class='online-navigation'><a rel="next" title="2.1 The Basics" | |
31 | href="dnt-basics.html"><img src='../icons/next.png' | |
32 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
33 | <td align="center" width="100%">Extending and Embedding the Python Interpreter</td> | |
34 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
35 | href="contents.html"><img src='../icons/contents.png' | |
36 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
37 | <td class='online-navigation'><img src='../icons/blank.png' | |
38 | border='0' height='32' alt='' width='32' /></td> | |
39 | <td class='online-navigation'><img src='../icons/blank.png' | |
40 | border='0' height='32' alt='' width='32' /></td> | |
41 | </tr></table> | |
42 | <div class='online-navigation'> | |
43 | <b class="navlabel">Previous:</b> | |
44 | <a class="sectref" rel="prev" href="using-cobjects.html">1.12 Providing a C</A> | |
45 | <b class="navlabel">Up:</b> | |
46 | <a class="sectref" rel="parent" href="ext.html">Extending and Embedding the</A> | |
47 | <b class="navlabel">Next:</b> | |
48 | <a class="sectref" rel="next" href="dnt-basics.html">2.1 The Basics</A> | |
49 | </div> | |
50 | <hr /></div> | |
51 | </DIV> | |
52 | <!--End of Navigation Panel--> | |
53 | ||
54 | <H1><A NAME="SECTION004000000000000000000"></A><A NAME="defining-new-types"></A> | |
55 | <BR> | |
56 | 2. Defining New Types | |
57 | ||
58 | </H1> | |
59 | ||
60 | <P> | |
61 | As mentioned in the last chapter, Python allows the writer of an | |
62 | extension module to define new types that can be manipulated from | |
63 | Python code, much like strings and lists in core Python. | |
64 | ||
65 | <P> | |
66 | This is not hard; the code for all extension types follows a pattern, | |
67 | but there are some details that you need to understand before you can | |
68 | get started. | |
69 | ||
70 | <P> | |
71 | <div class="note"><b class="label">Note:</b> | |
72 | The way new types are defined changed dramatically (and for the | |
73 | better) in Python 2.2. This document documents how to define new | |
74 | types for Python 2.2 and later. If you need to support older | |
75 | versions of Python, you will need to refer to older versions of this | |
76 | documentation. | |
77 | </div> | |
78 | ||
79 | <P> | |
80 | ||
81 | <p><br /></p><hr class='online-navigation' /> | |
82 | <div class='online-navigation'> | |
83 | <!--Table of Child-Links--> | |
84 | <A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></a> | |
85 | ||
86 | <UL CLASS="ChildLinks"> | |
87 | <LI><A href="dnt-basics.html">2.1 The Basics</a> | |
88 | <UL> | |
89 | <LI><A href="node22.html">2.1.1 Adding data and methods to the Basic example</a> | |
90 | <LI><A href="node23.html">2.1.2 Providing finer control over data attributes</a> | |
91 | <LI><A href="node24.html">2.1.3 Supporting cyclic garbage collection</a> | |
92 | </ul> | |
93 | <LI><A href="dnt-type-methods.html">2.2 Type Methods</a> | |
94 | <UL> | |
95 | <LI><A href="node26.html">2.2.1 Finalization and De-allocation</a> | |
96 | <LI><A href="node27.html">2.2.2 Object Presentation</a> | |
97 | <LI><A href="node28.html">2.2.3 Attribute Management</a> | |
98 | <UL> | |
99 | <LI><A href="node29.html">2.2.3.1 Generic Attribute Management</a> | |
100 | <LI><A href="node30.html">2.2.3.2 Type-specific Attribute Management</a> | |
101 | </ul> | |
102 | <LI><A href="node31.html">2.2.4 Object Comparison</a> | |
103 | <LI><A href="node32.html">2.2.5 Abstract Protocol Support</a> | |
104 | <LI><A href="node33.html">2.2.6 More Suggestions</a> | |
105 | </ul></ul> | |
106 | <!--End of Table of Child-Links--> | |
107 | </div> | |
108 | ||
109 | <DIV CLASS="navigation"> | |
110 | <div class='online-navigation'> | |
111 | <p></p><hr /> | |
112 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
113 | <tr> | |
114 | <td class='online-navigation'><a rel="prev" title="1.12 Providing a C" | |
115 | href="using-cobjects.html"><img src='../icons/previous.png' | |
116 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
117 | <td class='online-navigation'><a rel="parent" title="Extending and Embedding the" | |
118 | href="ext.html"><img src='../icons/up.png' | |
119 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
120 | <td class='online-navigation'><a rel="next" title="2.1 The Basics" | |
121 | href="dnt-basics.html"><img src='../icons/next.png' | |
122 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
123 | <td align="center" width="100%">Extending and Embedding the Python Interpreter</td> | |
124 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
125 | href="contents.html"><img src='../icons/contents.png' | |
126 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
127 | <td class='online-navigation'><img src='../icons/blank.png' | |
128 | border='0' height='32' alt='' width='32' /></td> | |
129 | <td class='online-navigation'><img src='../icons/blank.png' | |
130 | border='0' height='32' alt='' width='32' /></td> | |
131 | </tr></table> | |
132 | <div class='online-navigation'> | |
133 | <b class="navlabel">Previous:</b> | |
134 | <a class="sectref" rel="prev" href="using-cobjects.html">1.12 Providing a C</A> | |
135 | <b class="navlabel">Up:</b> | |
136 | <a class="sectref" rel="parent" href="ext.html">Extending and Embedding the</A> | |
137 | <b class="navlabel">Next:</b> | |
138 | <a class="sectref" rel="next" href="dnt-basics.html">2.1 The Basics</A> | |
139 | </div> | |
140 | </div> | |
141 | <hr /> | |
142 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> | |
143 | </DIV> | |
144 | <!--End of Navigation Panel--> | |
145 | <ADDRESS> | |
146 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. | |
147 | </ADDRESS> | |
148 | </BODY> | |
149 | </HTML> |