Boost logo

Boost :

From: John Hunter (jdhunter_at_[hidden])
Date: 2001-08-16 13:54:53

I am using boost python to wrap a simple C++ class. The class has a
member function which takes two optional arguments

class Order {
  void print( ostream& os=cout , string prefix = "") const;

When I tried to use this w/ the python lib, I got a frightening array
or compiler errors (included below). Can the python lib handle
optional args?

But since I only really need the default behavior from python, I wrote
an Order member func wrapper

  void testprint() const { this->print(); };

which works great (amazing library! move over SWIG).

But there is one interesting problem I am still having. In the python
wrapper, if I write

    Order_class.def(&Order::testprint, "testprint");

all is well, but if I write

    Order_class.def(&Order::testprint, "print");

I get an error when I try to run my python test script:

video:~/c/trade/python> ./
  File "./", line 5
SyntaxError: invalid syntax

What's going on with this? Any other name besides 'print' works fine
here. Is this because the Order::print method (which I am not
exposing to python) is somehow clashing??

John Hunter

Compiler rant when I try to expose the print method which has optional args
    Order_class.def(&Order::print, "print");

Boost list run by bdawes at, gregod at, cpdaniel at, john at