swigging polymorphic collections...

Bjorn Pettersen bjorn at roguewave.com
Mon Aug 30 08:19:26 EDT 1999


I've got a c++ class hierarchy rooted at Node:

	class Node { public: int n; };
	class SubNode1 : public Node { public: int sn1; };

and a list:

	class List {
		std::vector<Node*> lst;
	public:
		void  append(Node* n);
		Node* __getitem__(int key);
	};

So far everything is fine, however, when my c++ module returns a List, I can
never access "sn1" even though the actual Node is a SubNode1.

Has anyone found a solution to this?  Should I be using a PyList object
instead? -- how would I insert the nodes so they would be Python shadow
classes?

-- bjorn




More information about the Python-list mailing list