Adding an extension class using C++

shlychkov at gmail.com shlychkov at gmail.com
Thu Jan 12 14:10:34 EST 2006


I'm building a C++ program that encapsulates Python inside and has a
few extension classes with member variables and member functions. So
far almost everything is successful, I'm able to run scripts through
the utility, I can instantiate instances of my extension classes, I can
read/write member variables of the classes through class objects, but I
just cannot make member functions work properly. When I call a
function, I get the following message:
  exceptions.TypeError: 'NoneType' object is not callable
The way I extend Python is nothing (as far as I can see) different from
the documented way of doing it. This is my script:

from MyModule import *

def main():
	MyInstance = MyClass()

	MyInstance.memberVar1 = 1
	MyInstance.memberVar2 = 20
	MyInstance.memberVar3 = 300

	MyInstance.print()

If I comment out the last line, I get no messages, meaning good. I also
tried printing out values after I set them and it works flawlessly.
I would really appreciate if anybody could help me, because I'm at a
loss. It probably is something really stupid, but I just fail to see it
right now.

Please help.
Thanks!
Alex.




More information about the Python-list mailing list