You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This section is a cookbook of tricks and examples.
18
18
19
-
------------------------------------
19
+
====================================
20
20
Properties
21
-
------------------------------------
21
+
====================================
22
22
23
23
.. index::
24
24
single: New Types; Existing Python Properties
25
25
single: New Types; Existing C Properties
26
26
27
-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
27
+
------------------------------------
28
28
Referencing Existing Properties
29
-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
29
+
------------------------------------
30
30
31
31
If the property is part of the extension type then it is fairly easy to make it directly accessible as
32
32
`described here <https://docs.python.org/extending/newtypes.html#adding-data-and-methods-to-the-basic-example>`_
@@ -75,9 +75,9 @@ And the type struct must reference this array of ``PyMemberDef`` thus:
75
75
single: New Types; Dynamic Python Properties
76
76
single: New Types; Created Python Properties
77
77
78
-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
78
+
--------------------------
79
79
Created Properties
80
-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
80
+
--------------------------
81
81
82
82
If the properties are not directly accessible, for example they might need to be created, then an array of ``PyGetSetDef`` structures is used in the `PyTypeObject.tp_getset <https://docs.python.org/3/c-api/typeobj.html#c.PyTypeObject.tp_getset>`_ slot.
83
83
@@ -113,19 +113,19 @@ And the type struct must reference this array of ``PyMemberDef`` thus:
113
113
114
114
`Reference to PyGetSetDef. <https://docs.python.org/3/c-api/structures.html#c.PyGetSetDef>`_
115
115
116
-
---------------
116
+
====================================
117
117
Subclassing
118
-
---------------
118
+
====================================
119
119
120
120
This large subject gets it own chapter: :ref:`chapter_subclassing_and_using_super`.
121
121
122
122
123
123
.. index::
124
124
single: New Types; Examples
125
125
126
-
---------------
126
+
====================================
127
127
Examples
128
-
---------------
128
+
====================================
129
129
130
130
See ``src/cpy/cObject.c`` for some examples, the tests for these are in ``tests/unit/test_c_object.py``:
131
131
@@ -138,9 +138,9 @@ See ``src/cpy/cObject.c`` for some examples, the tests for these are in ``tests/
0 commit comments