Boost logo

Boost :

From: David Abrahams (abrahams_at_[hidden])
Date: 2001-02-14 16:00:18


----- Original Message -----
From: <rcspython_at_[hidden]>

> Greetings,
> I have been unable to locate how one goes about wrapping static class
> methods for use in Python. These methods simply return ints which
> indicate how many I/O ports are available for subsequent constructor
> calls.
>
> class myclass
> {
> public:
> static int BoardCount(void);
> static int ChannelCount(void);
> };
>
> Any help would be greatly appreciated!

Simply "def" them as you would any other member function, then access them
in Python through the class as you would in C++:
>>> myclass.BoardCount()

Any callable attribute of a BPL extension class has its first argument
automatically bound to the class instance when accessed through the
instance. If you must access the method through the instance, do it this
way:
>>> x = myclass()
>>> x.__class__.BoardCount()

> BTW, I was blown away how easy it was to actually get my class
> wrapped after struggling with SWIG... I was going to just wrap the
> class with C! This is a fantastic tool and I would love to help in
> expanding the documentation to facilitate the use by others!

Other people are already doing some work on this; your help and cooperation
would be greatly appreciated. I will have some time to incorporate other
peoples' efforts in the next few weeks.

Regards,
Dave


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk