simple CXX Q's: pls help

S. Hoon cpu at bigfoot.com
Sun May 30 15:37:58 EDT 1999


Hi,

  I have simple cxx Q's. (BTW: this is great I finally managed to write some
extension modules using sophisticated dictionary and tuples! Thanks LLNL.)
  Below is my code.:
static PyObject *
ex_Atuple(PyObject* self, PyObject* args)
{
 int i;
 double multval;
 List t,a;
 t = args[0];
 multval = args[1];
 for(i = 0; i < t.length(); i++)

            a.append(t[i]+multval);
  }
  try {
  return new_reference_to(a);
    }
    catch(const Exception&) {
        cout << "Exception caught HNtst, passing it on to Python\n";
        return Null ();
    }
}
What I am trying to do is that I want to send out ex_Atuple([12,3,4], 2)
from python
and get back : [24, 6, 4].
Eventually I would like to send out ex_Atuple(['a', 'b', 'c', 'd']) to be
transferred to a C++ **char Strptrs; .
Also would like to send dictionary as well at some point with checks to make
sure the args are List, tuple, or dict and take action accordingly.
If anyone has something already done, please send a e-mail to
mailto:hoon at bigfoot.com
Thanks much in Adv,

Hoon,

P.S.: Does LLNL offer docs on how to use Numpy with CXX as well? If a person
like me can figuire out how to write extension of C++ in couple of hours,
this anyone can!






More information about the Python-list mailing list