[C++-sig] How To Determine Return Policy???
David Abrahams
david.abrahams at rcn.com
Mon Jun 3 20:43:30 CEST 2002
----- Original Message -----
From: "chuzo okuda" <okuda1 at llnl.gov>
> Sorry, I forgot to add one more question.
> Is there a way to write BPL code that do not have to add "Tag*" to the
> argument for "static std::string str2()" in the source? I do not want to
> alter original source codes many people wrote.
You don't have to; static member functions can always be invoked from
Python as:
Tag.str2()
mirroring the C++
Tag::str2()
The fact that you can write
tag_instance.str2()
in C++ is almost a quirky accident. If you want to be able to write that
from Python, your best bet is to write a "thin wrapper function", and pass
that to def():
std::string my_str2(Tag*) { return Tag::str2(); }
...
.def("str2", &my_str2)
Eventually, we will have a way to define Python static functions so that
you can write both
Tag.str2()
and
tag_instance.str2()
from Python.
HTH,
Dave
More information about the Cplusplus-sig
mailing list