Is there a reason you need to call GetString()? I would recommend that you work around the problem by storing the strings in the Python script along with the corresponding OBSmartsPattern?
The underlying problem is that pointers to objects are not wrapped by the code. This is most easily fixed by changing the API. However, I don't like to do this if the problem can be worked around by the user. - Noel On 26 September 2011 16:59, Mingyue Zheng <myzh...@mail.shcnc.ac.cn> wrote: > Dear all, > openbabel.py provides an interface to use python scripts to call C/C++ > functions of open babel, > in which C built-in datatypes are mapped into the closest Python equivalent. > for example: > int, long, short <---> Python integers. > float, double <---> Python floats > char, char * <---> Python strings. > However, if a C++ function returns a variable with other datatypes, for > example: std:string, How can we deal with that? > Below is an example: > >>>import openbabel as ob >>>pat=ob.OBSmartsPatten() >>>pat.Init('c1ccccc1') >>>pat_str=pat.GetSMARTS() >>>print pat_str > > Since the function GetSMARTS() returns a std::string, > the printed result is not "c1ccccc1", > but a swig object like sth below: > "_20748c03_p_std__string" >>>pat_str > <Swig Object of type 'std::string *' at 0x03957AD0> > > Does anyone know how to deal with this problem? > > 2011-09-26 > ------------------------------------------------ > Mingyue Zheng, Ph.D. > Drug Discovery and Design Center (DDDC) > Box 1201, Shanghai Institute of Materia Medica. > No. 555 Rd. Zuchongzhi, Shanghai, China > Tel: 86-021-50806600-1308 > Email: myzh...@mail.shcnc.ac.cn > > ------------------------------------------------ > > > ------------------------------------------------------------------------------ > All the data continuously generated in your IT infrastructure contains a > definitive record of customers, application performance, security > threats, fraudulent activity and more. Splunk takes this data and makes > sense of it. Business sense. IT sense. Common sense. > http://p.sf.net/sfu/splunk-d2dcopy1 > _______________________________________________ > OpenBabel-discuss mailing list > OpenBabel-discuss@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/openbabel-discuss > ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2dcopy1 _______________________________________________ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss