[C++-sig] Static Methods
Francois Ostiguy
ostiguy at fnal.gov
Mon Nov 4 17:47:16 CET 2002
Hi-
In a message on this list on July 5, Dave Abrahams said:
>We don't have a way to make true static methods yet.
>getDims will work fine if you access it through the class like this:
>
> Nums.getDims()
>
>but not if you access it through the instance
>
> n = Nums()
> n.getDims() # error
>
>-Dave
I am assuming that the above statement remains true for the newly
released Boost.python v2.
I am trying to wrap the a static function Ring::initNodes().
(For reference, Ring is a class that inherits virtually from
other classes; I think this should be immaterial in the
present context).
When I import my module and try to run Ring::initValues(), here is what
get
>>> a = Ring()
>>> Ring.initValues()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: type object 'orbit.Ring' has no attribute 'initValues'
As it should be ... however
>>> Ring.initNodes()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: unbound method Boost.Python.function object must be called with
Ring instance as first argument (got nothing instead)
What am I missing ?
As always, help is greatly appreciated.
-Francois
----------------------------------------------------------------------------
Dr. Jean-Francois OSTIGUY voice: (630) 840-2231
Beam Physics Dept MS220 FAX: (630) 840-6039
Fermi National Accelerator Laboratory email: ostiguy at fnal.gov
Batavia IL 60510-0500 WWW:www-ap.fnal.gov/~ostiguy
More information about the Cplusplus-sig
mailing list