Extending Python in C ?'s
Andrew Murray
mr.murray at mindspring.com
Mon Sep 3 23:59:41 EDT 2001
Hi,
I'm looking into writing some types in C for use in a Python program
I'm working on. I've been reading and it looks really easy (especially
with SWIG) to create a simple type in C for use in python, but does anybody
know
how (or can point me to a good reasource on how) to create a type in C
whose data members would be other types written in C? For instance, if I
wanted to recreate this (ficticious) type:
Class myClass():
dataMembers = []
def __init__(self, integer_input):
i=0
while(i < integer_input):
dataMembers = append(myOtherClass("hello from # " + str(i))
def printMessages(self):
for member in self.dataMembers:
member.printMessage()
Class myOtherClass():
message = ''
def __init__(self, string_input):
self.message = string_input
def printMessage(self):
print self.message
I hope this example is clear... Please advise
Thanks,
Andrew Murray
More information about the Python-list
mailing list