swig or something else....

tALSit talsit at talsit.org
Sat Jul 6 10:40:00 EDT 2002


Hi, I'm trying to interface a system i made in C++ with python using swig.
Ok, i've got it working, but I find it pretty ugly. Actually, way ugly.

Given a C++ class:

class cNode {
public:
    cNode (const std::string & name);
    set (const std::string & attr, const std::string & value);
// etc
};

Swig generates a series of _functions_, not a class with methods, so in
python I have to do this:

obj = my_module.new_cNode ("someName")
my_module.cNode_set ("attrib", "value")

Instead of something more like this:

obj = my_module.cNode ("someName")
obj.set ("attrib", "value")

Is this a limitation of swig, python or am I doing it wrong?
Because if it's a swig limitation, I might be able to do a workaround for
the 3-4 classes i need interfacing. If it's python, well, it doesn't matter.
But if it's me, please advise!

Thanks!!






More information about the Python-list mailing list