By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,403 Members | 1,089 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,403 IT Pros & Developers. It's quick & easy.

py cxx callable

P: n/a

I am using pycxx 5.2.2. and am trying to write a callable class. The
docs suggest you need to override

virtual Object call( const Object &, const Object & );

in your extension and call supportcall in your init_type function, eg

void XYFunc::init_type()
behaviors().doc("Map x,y -> x,y");

I have a couple of questions:

* what are the two Object arguments to call? I would have expected
the signature to be

virtual Object call( const Py::Tuple& args);

* For testing, I defined a do nothing call, that just prints to std

class XYFunc : public Py::PythonExtension<XYFunc> {
static void init_type(void);
Py::Object call(const Py::Object &o1, const Py::Object &o2) {
std::cout << "you rang" << std::endl;
return Py::Object();

but I get the following error when I try and test it

from myext import XYFunc
x, y = 1,2
func = XYFunc()

Traceback (most recent call last):
File "", line 7, in ?
TypeError: CXX: type error.

Ditto when I pass func(x,y), func((x,y)) etc...

Any insight? I couldn't find any examples in distro that actually use

Jul 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.