How to extend inner classes?

hfellerm at uni-osnabrueck.de hfellerm at uni-osnabrueck.de
Sat Nov 27 12:02:35 EST 2004


Hi all,

I try to implement a C extension module that uses inner classes. The
structure of the corresponding python code is the following:

class PeriodicGrid :
    class Pos :
        # [...]

class NofluxGrid :
    class Pos :
        # [...]

I wrote the PyTypeObjects for PeriodicGrid, NofluxGrid, PeriodicPos, and
NofluxPos. Now I want to add each PosType to the appropriate Grid's
dictionary, so that I can write something like

>>> from cGrid import *
>>> grid = PeriodicGrid(10,10)
>>> pos = grid.Pos(1,2)

in my python program. What is the general way to add class members
(instead of instance members which is done by a PyMemberDef array) to the
PyTypeObject?

Any help appreciated,

- harold -




More information about the Python-list mailing list