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 3:16AM messages near this date
Re: [C++-sig] Static, again... | Re: [C++-sig] 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);
>     ...
>  }

Yep, this compiles just fine, but that is not the problem. 
Unfortunately, I cannot call it from Python without errors.
Here is what happens when I added the code to the hello example
(Cygwin/GCC BPV2):

$ python
Python 2.2.2 (#1, Nov 15 2002, 07:49:04)
[GCC 2.95.3-5 (cygwin special)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
> >> from hello import *
> >> X = Num()
> >> print X.dims()
5
> >> print X.getDims()
Traceback (most recent call last):
  File "<stdin> ", line 1, in ?
TypeError: bad argument type for built-in operation
> >> print Num().getDims()
Traceback (most recent call last):
  File "<stdin> ", line 1, in ?
TypeError: bad argument type for built-in operation
> >> print Num.getDims()
Traceback (most recent call last):
  File "<stdin> ", line 1, in ?
TypeError: unbound method Boost.Python.function object must
be called with Num instance as first argument (got nothing instead)

As you can see, the non-static method Num.dims() is fine, but
none of my attempts works for the static method. I think the
last invocation is supposed to work.

In BP V1 I could use Num.getDims(), but nothing works now?

Thanks, 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