Thank you Stephan, a few lines of your code have triggered a lot of sparks in my brain. >template <typename T> >void define_vec2(char const *name) >{ > typedef tvec2<T> vec2_type; > class_<vec2_type> vec2(name); > float (vec2_type::*swizzle_1)(comp) = &vec2_type::swizzle; > vec2.def("swizzle", swizzle_1); > //... >} > >and then call that function for all the value-types you want: > > define_vec2<float>("fvec2"); > define_vec2<int>("ivec2"); > //... I see that the template function approach is very useful for the number of value-types I have to work with (you guessed right), but I still have problems... 1) on the python interpreter, i have: >>> fvec2 < class '_ext.fvec2' > >>> int < type 'int' > Is there a standard way to make fvec2 become a real "type" in python, just like int? 2) I still can't do this from python >>> a = fvec2 (4.0,2.0) I realise that what I may be missing is .def("__init__", ... ) somewhere, but I don't know where, and how to initialize it properly. ( Also, I had to exclude the "swizzle" part(last 2 lines of the first section), because otherwise the program would no compile, but that's not the important part right? Thanks again,Robert
_______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig