<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Thank you David,
<p>But isn't this going to mess up the overloading?
<br>I also don't know how to create overloaded staticmethods in python.
<p>Nikolay
<p>David Abrahams wrote:
<blockquote TYPE=CITE>This is not the strategy I would've taken.&nbsp;
I think you should do
<br>something which mirrors pure Python:
<p>def foo(object):
<br>&nbsp;&nbsp;&nbsp; def f(x,y):
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return x*y
<br>&nbsp;&nbsp;&nbsp; f = staticmethod(f)
<p>So in C++, it would be something like:
<p>&nbsp;&nbsp; class_&lt;foo>("foo")
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .def("f", &amp;foo::f)
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .staticmethod("f")&nbsp;
// **
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;
<p>Where the marked line would be implemented something like this:
<p>&nbsp;&nbsp; self&amp; staticmethod(char const* name)
<br>&nbsp;&nbsp; {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this->attr(name) = object(handle&lt;>(
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
PyStaticMethod_New(this->attr(name).ptr())
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
));
<br>&nbsp;&nbsp; }
<p>--
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
David Abrahams
<br>&nbsp;&nbsp; dave@boost-consulting.com * <a href="http://www.boost-consulting.com">http://www.boost-consulting.com</a>
<br>Boost support, enhancements, training, and commercial distribution</blockquote>
</html>