ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> cpp-sig
cpp-sig
RE: [C++-sig] Static, again...
by Scott A. Smith other posts by this author
Dec 5 2002 12:53PM messages near this date
Re: [C++-sig] Static, again... | [C++-sig] Re: Static, again...
>  >David wrote:
>  >
>  >>A static member function is just a regular function; you can add it at
>  >>module scope:
>  >>
>  >>BOOST_PYTHON_MODULE_INIT(numTest)
>  >>{
>  >>   def("getDims", &Num::getDims);
>  >>   ...
>  >>}

Nicodemus wrote:

>  You are exposing a function, not a member function, so you should call 
>  it like this from python:
>  
>   >>> print getDims()
>  
>  If that bothers you, you can:
>  
>  1) Export it as "Num_getDims" instead of "getDims". It might be 
>  acceptable.
>  
>  
>  2) Create a static function on the python side, like this:
>  
>   >>> from hello import *
>   >>> Num.getDims = staticmethod(getDims)
>   >>> print Num.getDims()
>  
>  
>  3) Wait for David to implement the new facility to export static 
>  functions, which he said he would do as soon as he could, IIRC.

OK, I see now that it is the difference between adding

.def("getDims", &Num::getDims)

within the class Num and making it a regular function using

def("getDims", &Num::getDims);

I have to read David's responses more carefully. The solution
isn't optimal, but I can live with it until it is part of BP.
I am many many steps behind the cutting edge in BP anyway.

Thanks Dave & Nicodemus,
Scott


_______________________________________________
C++-sig mailing list
C++-sig@[...].org
http://mail.python.org/mailman/listinfo/c++-sig
Thread:
Hugo van der Merwe
Scott A. Smith
David Abrahams
Scott A. Smith
Nicodemus
Scott A. Smith
Mike Rovner
David Abrahams
David Abrahams
Hugo van der Merwe
Hugo van der Merwe
David Abrahams
Hugo van der Merwe
David Abrahams

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved