[C++-sig] Re: Boost.Python : Byref parameters - no problems with static/non-static overloading

David Abrahams dave at boost-consulting.com
Wed Oct 1 00:04:56 CEST 2003


Joel Gerard <llywelyn.geo at yahoo.com> writes:

> Ok.  I've got things mostly sorted out.  You can't overload static and non-static member
> functions, which is fine, but how do you use a static (not overloaded) function in Python? I need
> to keep the static function in the class scope. The reason is name collision, i.e.
>
> class A
> {
>    static void foo();
> }
>
> class B 
> {
>    static void foo();
> }

Do your static functions take the same sets of arguments?  If not,
name collision is OK because overloading will select the right one.

> I have:
> class Vector
> {
> public:
>     static  void        Orthonormalize          (Vector& kU, Vector& kV, Vector& kW);
> }
>
> Wrapped as:
>
>
> void (*Orthonormalize2)(Vector&, Vector&, Vector&)      = &Vector::Orthonormalize;
> .def("Orthonormalize",Orthonormalize2)
>             .staticmethod("Orthonormalize")
>
> In python, do you just use it as an unbound method?  Is the self argument non-existent in this
> case, or do I do something different?

See http://users.rcn.com/python/download/Descriptor.htm

> Currently I have:
> Vector.Orthonormalize (Vector1, Vector2, Vector3)
>
> Also, is there a good place to look for python examples. I didn't see a python example in the
> docs

Please post a doc bug in the Python bug database.
http://sourceforge.net/tracker/?group_id=5470


-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com





More information about the Cplusplus-sig mailing list