[C++-SIG] RE: [META-SIG] Terminating comatose SIGs
Paul Miller
paul at ra.avid.com
Wed Dec 17 22:01:51 CET 1997
Paul F. Dubois wrote:
> Dict a;
> a["hi"] = Stryng("ho");
> return a;
nice.
> try {
> List a;
> Tuple t(args);
> for(Tuple::iterator i = t.begin(); i != t.end(); i++) {
> a.append(*i);
> }
... nicer!
This all looks really good. What I'm even more interested in however is
easier writing of Python extension classes in C++. I've done a bit of
work here, as I'm providing a Python scripting interface into an
object-oriented 3D graphics application I'm leading.
FYI - I also did C++ wrappers for tuples and lists. However, I put my
C++ Python wrappers in "namespace Python" to avoid name collisions with
other things called "List" or "Tuple". I would recommend the same thing.
Another thing I did that may be useful to others is when writing an
extension function, I made some overloaded "Convert()" methods to call
when returning common values.
At the end of a function which is supposed to return Py_None for
example, you just call:
return Convert();
To return a "C" string, it's
return Convert("my string");
I didn't get far with making the Py_HEAD stuff and method registration
any nicer however.
--
Paul T. Miller | paul at elastic.avid.com
Principal Engineer | Opinions expressed here are my own.
Avid Technology, Inc. Madison - Graphics and Effects Software Group
_______________
C++-SIG - SIG for Development of a C++ Binding to Python
send messages to: c++-sig at python.org
administrivia to: c++-sig-request at python.org
_______________
More information about the Cplusplus-sig
mailing list