[C++-sig] static class variables

Francois Ostiguy ostiguy at fnal.gov
Sat Mar 8 00:34:22 CET 2003


Hi -

I recently experimented with the new "staticmethod" attribute to wrap
static class methods. I works beautifully ... great work !
This leads me to ask: is there any existing/planned equally convenient
way to wrap static class variables ?

I am thinking of something along the lines of

struct MyClass {
   double value1;
   double value2;
}


python::class_<MyClass>("MyClass")
  .def_readwrite("value2", &MyClass::value)
  .staticvariable("value2");                <<<<<< ?????????


so that from python I could simply say

MyClass.value2 = 2.0

As always, your help/comments/suggestions are 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